This file contains 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
... | |
TASK: [debug var=mydate] ****************************************************** | |
ok: [localhost] => { | |
"mydate": "20140605101824" | |
} | |
... |
This file contains 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
PLAY [foo] ******************************************************************** | |
GATHERING FACTS *************************************************************** | |
ok: [localhost] | |
TASK: [raw stat /tmp/foo] ***************************************************** | |
ok: [localhost -> 127.0.0.1] | |
TASK: [test_lib ] ************************************************************* | |
ok: [localhost] |
This file contains 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
--- | |
- hosts: localhost | |
connection: local | |
gather_facts: False | |
vars: | |
apache2_vhosts: | |
- name: "stage.example.org" | |
docroot: "/var/www/stage1" | |
- name: "stage2.example.org" | |
docroot: "/var/www/stage2" |
This file contains 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
PLAY [foo] ******************************************************************** | |
GATHERING FACTS *************************************************************** | |
ok: [localhost] | |
TASK: [set_fact ] ************************************************************* | |
ok: [localhost] | |
TASK: [debug ] **************************************************************** | |
ok: [localhost] => { |
This file contains 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
The problem: | |
I wanted to use the jinja 'map' filter to modify each item in a string, in this simple | |
example, adding '.conf' to each item. | |
The 'format' filter in jinja takes arguments (value, *args, **kwargs). Unfortunately, | |
it uses 'value' as the pattern. When called inside map 'value' is the current item in | |
the list, or in other words *args as far as format is concerned. So it's the wrong way | |
around. |
This file contains 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
--- | |
- hosts: localhost | |
connection: local | |
gather_facts: False | |
tasks: | |
# - include_vars: jsonfile.json | |
# | |
# - debug: | |
# var: ansible_devices | |
# |
This file contains 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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# Note: only works on RedHat family | |
# This library should be saved to the 'library/' folder relative to your playbooks/inventory | |
import rpm | |
def _check_installed(module): | |
ts = rpm.TransactionSet() |
This file contains 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
--- | |
- hosts: localhost | |
connection: local | |
gather_facts: False | |
tasks: | |
- debug: msg="call handler" | |
changed_when: True | |
notify: do something | |
handlers: |
This file contains 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
--- | |
- hosts: foo | |
tasks: | |
- name: register templates | |
local_action: shell ls {{ inventory_dir }}/path/to/templates | |
register: template_files | |
- template: src={{ item }} dest=/etc/httpd/conf.d/{{item}} | |
with_items: template_files.stdout_lines | |
This file contains 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
--- | |
- name: unable to access outer var in inner loop (in mysites.yml) | |
hosts: localhost | |
connection: local | |
gather_facts: False | |
vars: | |
mylist: | |
- foo | |
- bar | |
tasks: |