This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
# like this... | |
listofdict: | |
- key1: val1 | |
key2: val2 | |
- key1: val3 | |
key2: val4 | |
# or like this | |
listofdict2: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
# vim: set ft=ansible: | |
- name: fetchstuff | |
hosts: localhost | |
gather_facts: no | |
tasks: | |
- name: fetch it | |
fetch: | |
src: "/tmp/{{ item.name}}" | |
dest: "/tmp/dest/{{ item.name }}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# requires a version of python 2 | |
# "ansibleenv" can be anything you want, it creates a directory and populates it with python things | |
virtualenv ansibleenv | |
source ansibleenv/bin/activate | |
pip install ansible | |
# now you should be able to run ansible commands as usual | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
# vim: set ft=ansible: | |
- name: find files | |
hosts: localhost | |
tasks: | |
- name: find local configuration files | |
find: | |
paths: resources-minimal | |
patterns: "*.yml" | |
register: configfiles |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# first play | |
--- | |
# vim: set ft=ansible: | |
- name: includes test | |
hosts: all | |
gather_facts: no | |
tasks: | |
- debug: | |
msg: "{{ item }}" | |
with_items: "{{ play_hosts }}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
# vim: set ft=ansible: | |
- name: play test | |
hosts: localhost | |
gather_facts: no | |
vars: | |
url: "http://wibble.wobbble.com:9091/some/path?param=value¶m2=othervalue" | |
tasks: | |
- debug: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
# vim: set ft=ansible: | |
- name: split things | |
hosts: localhost | |
gather_facts: no | |
vars: | |
myname: "foo-bar-1.3.4.5.tar" | |
tasks: | |
- name: splitit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
# vim: set ft=ansible: | |
- name: subelements | |
hosts: localhost | |
gather_facts: no | |
vars: | |
static_hosts: | |
- host: test1 | |
ips: | |
- 192.168.0.1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static_hosts: | |
- host: test1 | |
- ip: 192.168.1.2 | |
- ip: 192.168.1.2 | |
- ip: 192.168.1.2 | |
- host: test2 | |
- ip: 127.0.0.1 | |
- ip: 127.1.0.1 | |
- ip: 127.1.0.2 | |
- ip: 127.1.0.3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
# vim: set ft=ansible: | |
- hosts: all | |
tasks: | |
- name: group hosts with random var | |
group_by: | |
key: random_var | |
when: random_var is defined | |
- name: prove it did stuff |