amazon web services - How to loop ansible variables -
i have below yml file working expected
--- - hosts: local - name: example of provisioning servers hosts: 127.0.0.1 connection: local tasks: - name: modify security group local_action: module: ec2_group name: ansible_trail description: modify sg rules region: us-east-1 rules: - proto: tcp from_port: 22 to_port: 22 cidr_ip: 198.168.45.23 purge_rules: true* i want repeat same action of security groups how in ansible .
instead of assigning name: optv5_ansible_trail want value list or file.
i'm not clear on you're asking, i'll give shot. want use with_items: http://docs.ansible.com/ansible/playbooks_loops.html#standard-loops
i'll take stab , might want this:
tasks: - name: modify security group local_action: module: ec2_group name: "{{ item }}" description: modify sg rules region: us-east-1 rules: - proto: tcp from_port: 22 to_port: 22 cidr_ip: 198.168.45.23 purge_rules: true* with_items: "{{ security_groups }}" where security_groups list of names of security groups. call local_action task 1 time each item in security_groups list, item current item in iteration.
you can use more complex data structures , access them dot notation (e.g. item.name, if security_groups list of dictionaries had key name).
Comments
Post a Comment