dimanche 31 mai 2015

Ansible -- ec2_group and ec2_tag in the same role?

I am trying to get an Ansible role with the ec2_group definition and the ec_tag on the same file as I would need to have it pretty compact.

For the ec2_tag I need the sg_id.. is there any way of getting that value dynamically?

Any way of doing anything like this?

roles/region-environment/tasks/env_sg_test.yml

- name: example ec2 group
  local_action:
    module: ec2_group
    name: my-security-group
    description: Access my-security-group
    vpc_id: "{{ vpc }}"
    region: "{{ region }}"
    rules:
      - proto: tcp
        from_port: 22
        to_port: 22
        cidr_ip: 0.0.0.0/0
      - proto: tcp
        from_port: 443
        to_port: 443
        cidr_ip: 0.0.0.0/0

- name: Tag the security group with a name
  local_action:
    module: ec2_tag
    resource: <----- Resource. SG_ID?
    region: "{{ region }}"
    state: present
    tags:
      Name: "My Security Group Name"
      env: "production"
      service: "web"

Thanks!!




Aucun commentaire:

Enregistrer un commentaire