Iterate over containerInstance feild

0 votes

 have a playbook that gets all container's ARNS in my aws ecs cluster

- name: List jenkins cluster container instances
  command: "aws ecs list-container-instances --cluster jenkins"
  register: jenkins_containers

- debug: var=jenkins_containers.stdout

output:

ok: [localhost] => {
    "jenkins_containers.stdout": {
        "containerInstanceArns": [
            "arn:aws:ecs:us-east-1:arn0", 
            "arn:aws:ecs:us-east-1:arn1", 
            "arn:aws:ecs:us-east-1:arn2"
        ]
    }
}​

How can I iterate over the containerInstanceArns field?

Apr 9, 2019 in Ansible by Laksha
950 views

1 answer to this question.

0 votes

Try something like this:

- name: List jenkins cluster container instances
  command: "aws ecs list-container-instances --cluster jenkins"
  register: jenkins_containers

- set_fact:
    containers: "{{ jenkins_containers.stdout }}"

- debug: msg="{{ item }}" 
  with_items: "{{ containers.containerInstanceArns }}"
answered Apr 9, 2019 by Anshul

Related Questions In Ansible

0 votes
1 answer

Ansible iterate over hash with condition

Your when statement is wrong. you either split ...READ MORE

answered Jul 23, 2018 in Ansible by Kalgi
• 52,350 points
1,384 views
0 votes
1 answer

One loop over multiple Ansible tasks

With_items has unfortunately stopped but it’s coming ...READ MORE

answered Jul 23, 2018 in Ansible by Kalgi
• 52,350 points
3,393 views
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
4,062 views
+2 votes
1 answer
0 votes
7 answers
+1 vote
12 answers

Iterate over a JSONObject?

Assuming your JSON object is saved in ...READ MORE

answered Dec 11, 2020 in Java by Rajiv
• 8,870 points
124,911 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP