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
12 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
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
• 35,880 points
121 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
• 35,880 points
449 views
+13 votes
2 answers
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
8,068 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.