Amazon ec2 Ansible中EC2组的标记名

Amazon ec2 Ansible中EC2组的标记名,amazon-ec2,ansible-playbook,Amazon Ec2,Ansible Playbook,这是来自以下帖子的另一个问题…: 所以基本上有: - name: EC2Group | Creating an EC2 Security Group inside the Mentioned VPC local_action: module: ec2_group name: "{{ item.sg_name }}" description: "{{ item.sg_description }}" re

这是来自以下帖子的另一个问题…:

所以基本上有:

    - name: EC2Group | Creating an EC2 Security Group inside the Mentioned VPC
       local_action:
         module: ec2_group
         name: "{{ item.sg_name }}"
         description: "{{ item.sg_description }}"
         region: "{{ vpc_region }}" # Change the AWS region here
         vpc_id: "{{ vpc.vpc_id }}" # vpc is the resgister name, you can also set it manually
         state: present
         rules: "{{ item.sg_rules }}"
       with_items: ec2_security_groups
       register: aws_sg
- name: Tag the security group with a name
  local_action:
   module: ec2_tag
   resource: "{{ item.group_id }}"
   region: "{{ vpc_region }}"
   state: present
   tags:
     Name: "{{vpc_name }}-group"
  with_items: aws_sg.results
我想知道怎样才能得到标签名

 tags:
     Name: "{{ item.sg_name }}"
是否与安全组上的主名称定义的值相同

   local_action:
     module: ec2_group
     name: "{{ item.sg_name }}"
我正在努力做到这一点,但我不知道如何做到这一点。是否也可以检索该项目


谢谢

在运行ec2.py清单脚本后,标签可用-它们始终采用
tag\u key\u value
的值,其中“key”是标签的名称,“value”是该标签内的值。i、 e.如果您创建一个名为“Application”的标记,并给它一个值“AwesomeApplication”,您将得到“tag\u Application\u AwesomeApplication”

也就是说,如果您刚刚创建了实例,并且希望对这些新实例运行一些命令,请解析create instance命令的输出以获得IP地址列表,并将其添加到临时组中,然后您可以在同一剧本中对该组运行命令:

...
    - name: add hosts to temporary group
      add_host: name="{{ item }}" groups=temporarygroup
      with_items: parsedipaddresses
- hosts: temporarygroup
  tasks:
    - name: awesome script to do stuff goes here
...

你好我的问题与ec2_group.py有关,因为我正在创建组,这些标记应该只用于组。我遇到的问题只是标记名,因为我不知道如何从module:ec2_组中提取它,以便将该值从ec2_标记模块导入到标记名中