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 8 in Ansible by Laksha
26 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 8 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
• 42,510 points
223 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
• 42,510 points
866 views
+13 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 26, 2018 in DevOps & Agile by DragonLord999
• 8,380 points
216 views
0 votes
1 answer
0 votes
7 answers
+1 vote
10 answers

Iterate over a JSONObject?

You can use the following method to ...READ MORE

answered Dec 7, 2018 in Java by Shuvodip
19,093 views