Skip to content

Instantly share code, notes, and snippets.

@srgvg
Last active December 26, 2015 04:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save srgvg/7092035 to your computer and use it in GitHub Desktop.
Save srgvg/7092035 to your computer and use it in GitHub Desktop.
- hosts: localhost
gather_facts: false
connection: local
vars:
list1:
- 'a'
- 'b'
- 'c'
- 'd'
list2:
- 1
- 2
- 3
- 4
lists:
- list1
- list2
users:
- paul
- john
- ringo
- george
tasks:
- name: items
debug: msg="{{item}}"
with_items:
- lookup('first_found', '/etc/network/interfaces', '/etc/sysconfig/network')
- lookup('file', '/etc/hostname')
- lookup('pipe', 'hostname --fqdn')
- lookup('lines', 'ls /boot/grub/')
- name: flattened
debug: msg="{{item}}"
with_flattened:
- lookup('first_found', '/etc/sysconfig/network', '/etc/network/interfaces')
- lookup('fileglob', '/etc/pam.d/*')
- lookup('flattened', lists)
- lookup('nested', list1, list2)
- lookup('pipe', 'hostname --fqdn')
- lookup('together', lists)
- lookup('sequence', 'start=5 end=10 stride=5')
- name: nested
debug: msg="{{item}}"
with_nested:
- users
- lookup('fileglob', '/etc/cron.d/*')
- name: together
debug: msg="{{item}}"
with_together:
- lookup('flattened', lists)
- lookup('flattened', lists)
- name: nesting items and random_choice plugins doesn't work - those don't template enough?
debug: msg="{{item}}"
with_nested:
- lookup('items', list1, list2)
- lookup('random_choice', lists)
Tuesday 22 October 2013 00:28:23 +0200
PLAY [localhost] **************************************************************
Tuesday 22 October 2013 00:28:23 +0200
TASK: [items] *****************************************************************
Tuesday 22 October 2013 00:28:23 +0200
ok: [localhost] => (item=/etc/network/interfaces) => {
"item": "/etc/network/interfaces",
"msg": "/etc/network/interfaces"
}
ok: [localhost] => (item=cyberlab) => {
"item": "cyberlab",
"msg": "cyberlab"
}
ok: [localhost] => (item=cyberlab.lan.vanginderachter.be) => {
"item": "cyberlab.lan.vanginderachter.be",
"msg": "cyberlab.lan.vanginderachter.be"
}
ok: [localhost] => (item=fonts) => {
"item": "fonts",
"msg": "fonts"
}
ok: [localhost] => (item=gfxblacklist.txt) => {
"item": "gfxblacklist.txt",
"msg": "gfxblacklist.txt"
}
ok: [localhost] => (item=grub.cfg) => {
"item": "grub.cfg",
"msg": "grub.cfg"
}
ok: [localhost] => (item=grubenv) => {
"item": "grubenv",
"msg": "grubenv"
}
ok: [localhost] => (item=i386-pc) => {
"item": "i386-pc",
"msg": "i386-pc"
}
ok: [localhost] => (item=locale) => {
"item": "locale",
"msg": "locale"
}
ok: [localhost] => (item=unicode.pf2) => {
"item": "unicode.pf2",
"msg": "unicode.pf2"
}
TASK: [flattened] *************************************************************
Tuesday 22 October 2013 00:28:23 +0200
ok: [localhost] => (item=/etc/network/interfaces) => {
"item": "/etc/network/interfaces",
"msg": "/etc/network/interfaces"
}
ok: [localhost] => (item=/etc/pam.d/atd) => {
"item": "/etc/pam.d/atd",
"msg": "/etc/pam.d/atd"
}
ok: [localhost] => (item=/etc/pam.d/common-session) => {
"item": "/etc/pam.d/common-session",
"msg": "/etc/pam.d/common-session"
}
ok: [localhost] => (item=/etc/pam.d/common-account) => {
"item": "/etc/pam.d/common-account",
"msg": "/etc/pam.d/common-account"
}
ok: [localhost] => (item=/etc/pam.d/lightdm) => {
"item": "/etc/pam.d/lightdm",
"msg": "/etc/pam.d/lightdm"
}
ok: [localhost] => (item=/etc/pam.d/chpasswd) => {
"item": "/etc/pam.d/chpasswd",
"msg": "/etc/pam.d/chpasswd"
}
ok: [localhost] => (item=/etc/pam.d/common-password) => {
"item": "/etc/pam.d/common-password",
"msg": "/etc/pam.d/common-password"
}
ok: [localhost] => (item=/etc/pam.d/cups-daemon) => {
"item": "/etc/pam.d/cups-daemon",
"msg": "/etc/pam.d/cups-daemon"
}
ok: [localhost] => (item=/etc/pam.d/lightdm-remote-freerdp) => {
"item": "/etc/pam.d/lightdm-remote-freerdp",
"msg": "/etc/pam.d/lightdm-remote-freerdp"
}
ok: [localhost] => (item=/etc/pam.d/lightdm-greeter) => {
"item": "/etc/pam.d/lightdm-greeter",
"msg": "/etc/pam.d/lightdm-greeter"
}
ok: [localhost] => (item=/etc/pam.d/cron) => {
"item": "/etc/pam.d/cron",
"msg": "/etc/pam.d/cron"
}
ok: [localhost] => (item=/etc/pam.d/common-auth) => {
"item": "/etc/pam.d/common-auth",
"msg": "/etc/pam.d/common-auth"
}
ok: [localhost] => (item=/etc/pam.d/chfn) => {
"item": "/etc/pam.d/chfn",
"msg": "/etc/pam.d/chfn"
}
ok: [localhost] => (item=/etc/pam.d/passwd) => {
"item": "/etc/pam.d/passwd",
"msg": "/etc/pam.d/passwd"
}
ok: [localhost] => (item=/etc/pam.d/gnome-screensaver) => {
"item": "/etc/pam.d/gnome-screensaver",
"msg": "/etc/pam.d/gnome-screensaver"
}
ok: [localhost] => (item=/etc/pam.d/sshd) => {
"item": "/etc/pam.d/sshd",
"msg": "/etc/pam.d/sshd"
}
ok: [localhost] => (item=/etc/pam.d/polkit-1) => {
"item": "/etc/pam.d/polkit-1",
"msg": "/etc/pam.d/polkit-1"
}
ok: [localhost] => (item=/etc/pam.d/ppp) => {
"item": "/etc/pam.d/ppp",
"msg": "/etc/pam.d/ppp"
}
ok: [localhost] => (item=/etc/pam.d/login) => {
"item": "/etc/pam.d/login",
"msg": "/etc/pam.d/login"
}
ok: [localhost] => (item=/etc/pam.d/cups) => {
"item": "/etc/pam.d/cups",
"msg": "/etc/pam.d/cups"
}
ok: [localhost] => (item=/etc/pam.d/xscreensaver) => {
"item": "/etc/pam.d/xscreensaver",
"msg": "/etc/pam.d/xscreensaver"
}
ok: [localhost] => (item=/etc/pam.d/su) => {
"item": "/etc/pam.d/su",
"msg": "/etc/pam.d/su"
}
ok: [localhost] => (item=/etc/pam.d/i3lock) => {
"item": "/etc/pam.d/i3lock",
"msg": "/etc/pam.d/i3lock"
}
ok: [localhost] => (item=/etc/pam.d/chsh) => {
"item": "/etc/pam.d/chsh",
"msg": "/etc/pam.d/chsh"
}
ok: [localhost] => (item=/etc/pam.d/sudo) => {
"item": "/etc/pam.d/sudo",
"msg": "/etc/pam.d/sudo"
}
ok: [localhost] => (item=/etc/pam.d/newusers) => {
"item": "/etc/pam.d/newusers",
"msg": "/etc/pam.d/newusers"
}
ok: [localhost] => (item=/etc/pam.d/lightdm-autologin) => {
"item": "/etc/pam.d/lightdm-autologin",
"msg": "/etc/pam.d/lightdm-autologin"
}
ok: [localhost] => (item=/etc/pam.d/common-session-noninteractive) => {
"item": "/etc/pam.d/common-session-noninteractive",
"msg": "/etc/pam.d/common-session-noninteractive"
}
ok: [localhost] => (item=/etc/pam.d/other) => {
"item": "/etc/pam.d/other",
"msg": "/etc/pam.d/other"
}
ok: [localhost] => (item=/etc/pam.d/samba) => {
"item": "/etc/pam.d/samba",
"msg": "/etc/pam.d/samba"
}
ok: [localhost] => (item=/etc/pam.d/lightdm-remote-uccsconfigure) => {
"item": "/etc/pam.d/lightdm-remote-uccsconfigure",
"msg": "/etc/pam.d/lightdm-remote-uccsconfigure"
}
ok: [localhost] => (item=a) => {
"item": "a",
"msg": "a"
}
ok: [localhost] => (item=b) => {
"item": "b",
"msg": "b"
}
ok: [localhost] => (item=c) => {
"item": "c",
"msg": "c"
}
ok: [localhost] => (item=d) => {
"item": "d",
"msg": "d"
}
ok: [localhost] => (item=1) => {
"item": 1,
"msg": "1"
}
ok: [localhost] => (item=2) => {
"item": 2,
"msg": "2"
}
ok: [localhost] => (item=3) => {
"item": 3,
"msg": "3"
}
ok: [localhost] => (item=4) => {
"item": 4,
"msg": "4"
}
ok: [localhost] => (item=a) => {
"item": "a",
"msg": "a"
}
ok: [localhost] => (item=1) => {
"item": 1,
"msg": "1"
}
ok: [localhost] => (item=a) => {
"item": "a",
"msg": "a"
}
ok: [localhost] => (item=2) => {
"item": 2,
"msg": "2"
}
ok: [localhost] => (item=a) => {
"item": "a",
"msg": "a"
}
ok: [localhost] => (item=3) => {
"item": 3,
"msg": "3"
}
ok: [localhost] => (item=a) => {
"item": "a",
"msg": "a"
}
ok: [localhost] => (item=4) => {
"item": 4,
"msg": "4"
}
ok: [localhost] => (item=b) => {
"item": "b",
"msg": "b"
}
ok: [localhost] => (item=1) => {
"item": 1,
"msg": "1"
}
ok: [localhost] => (item=b) => {
"item": "b",
"msg": "b"
}
ok: [localhost] => (item=2) => {
"item": 2,
"msg": "2"
}
ok: [localhost] => (item=b) => {
"item": "b",
"msg": "b"
}
ok: [localhost] => (item=3) => {
"item": 3,
"msg": "3"
}
ok: [localhost] => (item=b) => {
"item": "b",
"msg": "b"
}
ok: [localhost] => (item=4) => {
"item": 4,
"msg": "4"
}
ok: [localhost] => (item=c) => {
"item": "c",
"msg": "c"
}
ok: [localhost] => (item=1) => {
"item": 1,
"msg": "1"
}
ok: [localhost] => (item=c) => {
"item": "c",
"msg": "c"
}
ok: [localhost] => (item=2) => {
"item": 2,
"msg": "2"
}
ok: [localhost] => (item=c) => {
"item": "c",
"msg": "c"
}
ok: [localhost] => (item=3) => {
"item": 3,
"msg": "3"
}
ok: [localhost] => (item=c) => {
"item": "c",
"msg": "c"
}
ok: [localhost] => (item=4) => {
"item": 4,
"msg": "4"
}
ok: [localhost] => (item=d) => {
"item": "d",
"msg": "d"
}
ok: [localhost] => (item=1) => {
"item": 1,
"msg": "1"
}
ok: [localhost] => (item=d) => {
"item": "d",
"msg": "d"
}
ok: [localhost] => (item=2) => {
"item": 2,
"msg": "2"
}
ok: [localhost] => (item=d) => {
"item": "d",
"msg": "d"
}
ok: [localhost] => (item=3) => {
"item": 3,
"msg": "3"
}
ok: [localhost] => (item=d) => {
"item": "d",
"msg": "d"
}
ok: [localhost] => (item=4) => {
"item": 4,
"msg": "4"
}
ok: [localhost] => (item=cyberlab.lan.vanginderachter.be) => {
"item": "cyberlab.lan.vanginderachter.be",
"msg": "cyberlab.lan.vanginderachter.be"
}
ok: [localhost] => (item=a) => {
"item": "a",
"msg": "a"
}
ok: [localhost] => (item=b) => {
"item": "b",
"msg": "b"
}
ok: [localhost] => (item=c) => {
"item": "c",
"msg": "c"
}
ok: [localhost] => (item=d) => {
"item": "d",
"msg": "d"
}
ok: [localhost] => (item=1) => {
"item": 1,
"msg": "1"
}
ok: [localhost] => (item=2) => {
"item": 2,
"msg": "2"
}
ok: [localhost] => (item=3) => {
"item": 3,
"msg": "3"
}
ok: [localhost] => (item=4) => {
"item": 4,
"msg": "4"
}
ok: [localhost] => (item=5) => {
"item": "5",
"msg": "5"
}
ok: [localhost] => (item=10) => {
"item": "10",
"msg": "10"
}
TASK: [nested] ****************************************************************
Tuesday 22 October 2013 00:28:23 +0200
ok: [localhost] => (item=['paul', '/etc/cron.d/anacron']) => {
"item": [
"paul",
"/etc/cron.d/anacron"
],
"msg": "['paul', '/etc/cron.d/anacron']"
}
ok: [localhost] => (item=['paul', '/etc/cron.d/sysstat']) => {
"item": [
"paul",
"/etc/cron.d/sysstat"
],
"msg": "['paul', '/etc/cron.d/sysstat']"
}
ok: [localhost] => (item=['paul', '/etc/cron.d/mdadm']) => {
"item": [
"paul",
"/etc/cron.d/mdadm"
],
"msg": "['paul', '/etc/cron.d/mdadm']"
}
ok: [localhost] => (item=['paul', '/etc/cron.d/rsnapshot']) => {
"item": [
"paul",
"/etc/cron.d/rsnapshot"
],
"msg": "['paul', '/etc/cron.d/rsnapshot']"
}
ok: [localhost] => (item=['john', '/etc/cron.d/anacron']) => {
"item": [
"john",
"/etc/cron.d/anacron"
],
"msg": "['john', '/etc/cron.d/anacron']"
}
ok: [localhost] => (item=['john', '/etc/cron.d/sysstat']) => {
"item": [
"john",
"/etc/cron.d/sysstat"
],
"msg": "['john', '/etc/cron.d/sysstat']"
}
ok: [localhost] => (item=['john', '/etc/cron.d/mdadm']) => {
"item": [
"john",
"/etc/cron.d/mdadm"
],
"msg": "['john', '/etc/cron.d/mdadm']"
}
ok: [localhost] => (item=['john', '/etc/cron.d/rsnapshot']) => {
"item": [
"john",
"/etc/cron.d/rsnapshot"
],
"msg": "['john', '/etc/cron.d/rsnapshot']"
}
ok: [localhost] => (item=['ringo', '/etc/cron.d/anacron']) => {
"item": [
"ringo",
"/etc/cron.d/anacron"
],
"msg": "['ringo', '/etc/cron.d/anacron']"
}
ok: [localhost] => (item=['ringo', '/etc/cron.d/sysstat']) => {
"item": [
"ringo",
"/etc/cron.d/sysstat"
],
"msg": "['ringo', '/etc/cron.d/sysstat']"
}
ok: [localhost] => (item=['ringo', '/etc/cron.d/mdadm']) => {
"item": [
"ringo",
"/etc/cron.d/mdadm"
],
"msg": "['ringo', '/etc/cron.d/mdadm']"
}
ok: [localhost] => (item=['ringo', '/etc/cron.d/rsnapshot']) => {
"item": [
"ringo",
"/etc/cron.d/rsnapshot"
],
"msg": "['ringo', '/etc/cron.d/rsnapshot']"
}
ok: [localhost] => (item=['george', '/etc/cron.d/anacron']) => {
"item": [
"george",
"/etc/cron.d/anacron"
],
"msg": "['george', '/etc/cron.d/anacron']"
}
ok: [localhost] => (item=['george', '/etc/cron.d/sysstat']) => {
"item": [
"george",
"/etc/cron.d/sysstat"
],
"msg": "['george', '/etc/cron.d/sysstat']"
}
ok: [localhost] => (item=['george', '/etc/cron.d/mdadm']) => {
"item": [
"george",
"/etc/cron.d/mdadm"
],
"msg": "['george', '/etc/cron.d/mdadm']"
}
ok: [localhost] => (item=['george', '/etc/cron.d/rsnapshot']) => {
"item": [
"george",
"/etc/cron.d/rsnapshot"
],
"msg": "['george', '/etc/cron.d/rsnapshot']"
}
TASK: [together] **************************************************************
Tuesday 22 October 2013 00:28:23 +0200
ok: [localhost] => (item=['a', 'a']) => {
"item": [
"a",
"a"
],
"msg": "['a', 'a']"
}
ok: [localhost] => (item=['b', 'b']) => {
"item": [
"b",
"b"
],
"msg": "['b', 'b']"
}
ok: [localhost] => (item=['c', 'c']) => {
"item": [
"c",
"c"
],
"msg": "['c', 'c']"
}
ok: [localhost] => (item=['d', 'd']) => {
"item": [
"d",
"d"
],
"msg": "['d', 'd']"
}
ok: [localhost] => (item=[1, 1]) => {
"item": [
1,
1
],
"msg": "[1, 1]"
}
ok: [localhost] => (item=[2, 2]) => {
"item": [
2,
2
],
"msg": "[2, 2]"
}
ok: [localhost] => (item=[3, 3]) => {
"item": [
3,
3
],
"msg": "[3, 3]"
}
ok: [localhost] => (item=[4, 4]) => {
"item": [
4,
4
],
"msg": "[4, 4]"
}
TASK: [nesting items and random_choice plugins doesn't work - those don't template enough?] ***
Tuesday 22 October 2013 00:28:23 +0200
ok: [localhost] => (item=['list1', 'lists']) => {
"item": [
"list1",
"lists"
],
"msg": "['list1', 'lists']"
}
ok: [localhost] => (item=['list2', 'lists']) => {
"item": [
"list2",
"lists"
],
"msg": "['list2', 'lists']"
}
PLAY RECAP ********************************************************************
Total elapsed time: 0:00:00.153
localhost : ok=5 changed=0 unreachable=0 failed=0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment