简体   繁体   English

Chef AWS驱动程序标签无法在Etc.getlogin中使用

[英]Chef aws driver tags don't work using Etc.getlogin

I am currently using Chef solo on a Windows machine. 我目前在Windows计算机上单独使用Chef。 I used the fog driver before which created tags for my instances on AWS. 我使用了雾驱动程序,然后才在AWS上为我的实例创建标签。 Recently, I moved to the aws driver and noticed that aws driver does not handle tagging. 最近,我移至aws驱动程序,并注意到aws驱动程序无法处理标记。 I tried writing my own code to create the tags. 我尝试编写自己的代码来创建标签。 One of the tags being "Owner" which tells me who created the instance. 标签之一是“所有者”,它告诉我创建实例的人。 For this, I am using the following code: 为此,我使用以下代码:

  def get_admin_machine_options()
    case get_provisioner()
    when "cccis-environments-aws"

      general_machine_options = {ssh_username: "root",
        create_timeout: 7000,
        use_private_ip_for_ssh: true,
        aws_tags: {Owner: Etc.getlogin.to_s}
      }

      general_bootstrap_options = {
        key_name: KEY_NAME,
        image_id:  "AMI",
        instance_type: "m3.large",
        subnet_id: "subnet",
        security_group_ids: ["sg-"],
      }

      bootstrap_options = Chef::Mixin::DeepMerge.hash_only_merge(general_bootstrap_options,{})

      return Chef::Mixin::DeepMerge.hash_only_merge(general_machine_options, {bootstrap_options: bootstrap_options})

    else
      raise "Unknown provisioner #{get_setting('CHEF_PROFILE')}"
    end
  end

  machine admin_name do
        recipe "random.rb"
        machine_options get_admin_machine_options()
        ohai_hints ohai_hints
        action $provisioningAction
  end

Now, this works fine on my machine. 现在,这在我的机器上可以正常工作。 The instance is created on my machine with proper tags but when I run the same code on someone else's machine. 该实例是在我的计算机上创建的,带有适当的标记,但是当我在其他人的计算机上运行相同的代码时。 It doesn't create the tags at all. 它根本不会创建标签。 I find this to be very weird. 我觉得这很奇怪。 Does anyone know what's happening? 有人知道发生了什么吗? I have the same code! 我有相同的代码!

Okay so I found the issue. 好的,所以我找到了问题。 I was using the gem chef-provisioning-aws 1.2.1 and everyone else was on 1.1.1 我使用的是宝石厨师调配锯1.2.1,其他所有人都在1.1.1上

the gem 1.1.1 does not have support for tagging so it just went right past it. gem 1.1.1不支持标记,因此刚过去。

I uninstalled the old gem and installed the new one. 我卸载了旧的gem,然后安装了新的gem。 It worked like a charm! 它就像一个魅力!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM