Skip to content

Instantly share code, notes, and snippets.

- name: Install Apache
apt: name={{ item }} state=present
with_items:
- apache2-mpm-prefork
- libapache2-mod-php5
tasks:
- name: install prerequisite packages
apt:
update_cache: yes
name: "{{ item }}"
install_recommends: no
state: latest
with_items:
- nginx
- python-pip
Space-separated values: {{ (l1+l2+l3)|join(" ") }}
- name: Terminate legacy instance(s)
ec2:
region: '{{ region }}'
zone: '{{ zone }}'
keypair: '{{ keypair }}'
group: '{{ security_group }}'
image: '{{ image }}'
instance_ids: '{{ ansible_ec2_instance_id }}'
state: absent
wait: yes
[root@awxbox2 ~]# supervisorctl stop awx-celeryd
^[[A^CTraceback (most recent call last):
File "/usr/bin/supervisorctl", line 6, in <module>
main()
File "/usr/lib/python2.6/site-packages/supervisor/supervisorctl.py", line 598, in main
c.onecmd(" ".join(options.args))
File "/usr/lib/python2.6/site-packages/supervisor/supervisorctl.py", line 86, in onecmd
return func(arg)
File "/usr/lib/python2.6/site-packages/supervisor/supervisorctl.py", line 433, in do_stop
result = supervisor.stopProcess(processname)
- name: my sudo task
command: uptime
sudo: yes
---
- hosts: localhost
connection: local
gather_facts: false
tasks:
- name: Create the security group
ec2_group:
name: sshonly
Timothys-MacBook-Pro:ansible-test tgerla$ ansible-playbook -i localhost, test-vars.yml
PLAY [localhost] **************************************************************
GATHERING FACTS ***************************************************************
ok: [localhost]
TASK: [debug msg="VLAN for our IP is {{ip_vlan_mapping[ip]}}"] ****************
ok: [localhost] => {
"msg": "VLAN for our IP is 997"
- name: do something not sudo
command: echo hello
sudo: no
- name: test file existence
stat: file=filename.txt
register: st
- name: do something
shell: ...
when: st.stat.exists