Skip to content

Instantly share code, notes, and snippets.

@eclecticmiraclecat
Created February 17, 2021 16:38
Show Gist options
  • Save eclecticmiraclecat/76e90d7f180978afae925a26e1cefa7e to your computer and use it in GitHub Desktop.
Save eclecticmiraclecat/76e90d7f180978afae925a26e1cefa7e to your computer and use it in GitHub Desktop.
# nested_loos.yml
---

- name: Network Getting Started First Playbook
  hosts: all
  tasks:
    - name: say hello using nested loops
      debug: msg="The value {{ item[0] }} and {{ item[1] }}"
      with_nested:
        - [ 'alice', 'bob'] # item[0]
        - [ 'blue', 'pink', 'green'] # item[1]
$ ansible-playbook -i 'localhost,' -c local nested_loops.yml
ok: [localhost] => (item=[u'alice', u'blue']) => {
   "msg": "The value alice and blue"
}
ok: [localhost] => (item=[u'alice', u'pink']) => {
   "msg": "The value alice and pink"
}
ok: [localhost] => (item=[u'alice', u'green']) => {
   "msg": "The value alice and green"
}
ok: [localhost] => (item=[u'bob', u'blue']) => {
   "msg": "The value bob and blue"
}
ok: [localhost] => (item=[u'bob', u'pink']) => {
   "msg": "The value bob and pink"
}
ok: [localhost] => (item=[u'bob', u'green']) => {
   "msg": "The value bob and green"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment