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
--- | |
- hosts: all | |
connection: local | |
tasks: | |
- name: run a sample command | |
command: uptime | |
register: uptimeOutput |
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
tasks: | |
- name: install prerequisite packages | |
apt: | |
update_cache: yes | |
name: "{{ item }}" | |
install_recommends: no | |
state: latest | |
with_items: | |
- nginx | |
- python-pip |
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
- name: Install Apache | |
apt: name={{ item }} state=present | |
with_items: | |
- apache2-mpm-prefork | |
- libapache2-mod-php5 |
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
Output with --extra-vars "hosts=foo": | |
Timothys-MacBook-Pro:ansible-test tgerla$ ansible-playbook -i inventory2 test-nulty.py --extra-vars "hosts=foo" -c local | |
PLAY [foo] ******************************************************************** | |
skipping: no hosts matched | |
PLAY RECAP ******************************************************************** | |
Output with --extra-vars "hosts= foo": |
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
--- | |
my_dict: | |
blargh: "{{ registered_foo }}" | |
blerf: "{{ registered_bar }}" |
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
#!/usr/bin/python | |
import sys | |
import os | |
from ansible.module_utils.basic import * | |
def main(): | |
facts = {} | |
module = AnsibleModule(argument_spec={}) |
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
{% for host in groups['mygroup'] %} | |
{% if host != inventory_hostname %} | |
...something {{host}} | |
{% endif %} | |
{% endfor %} |
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
import ansible.utils as utils | |
# | |
# Put this file in lookup_plugins/ alongside your playbooks. | |
# | |
# Lookup plugins can be called two ways: via with_ as a task loop | |
# construct, or via lookup('name'). | |
# | |
# You can find the code for the basic lookup plugins here: | |
# v1: https://github.com/ansible/ansible/tree/devel/v1/ansible/runner/lookup_plugins | |
# v2: https://github.com/ansible/ansible/tree/devel/lib/ansible/plugins/lookup |
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
--- | |
myList: | |
- one | |
- two | |
- three | |
main_datastructure: | |
myList: "{{ myList }}" |
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
vagrant@vagrant-ubuntu-trusty-64:~$ sudo apt-add-repository ppa:ansible/ansible | |
Ansible is a radically simple IT automation platform that makes your applications and systems easier to deploy. Avoid writing scripts or custom code to deploy and update your applications— automate in a language that approaches plain English, using SSH, with no agents to install on remote systems. | |
http://ansible.com/ | |
More info: https://launchpad.net/~ansible/+archive/ubuntu/ansible | |
Press [ENTER] to continue or ctrl-c to cancel adding it | |
gpg: keyring `/tmp/tmpyb8hljmx/secring.gpg' created | |
gpg: keyring `/tmp/tmpyb8hljmx/pubring.gpg' created | |
gpg: requesting key 7BB9C367 from hkp server keyserver.ubuntu.com |