Skip to content

Instantly share code, notes, and snippets.

---
- hosts: localhost
connection: local
gather_facts: false
tasks:
- name: Create the security group
ec2_group:
name: sshonly
- name: my sudo task
command: uptime
sudo: 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: 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
Space-separated values: {{ (l1+l2+l3)|join(" ") }}
diff --git a/lib/ansible/runner/__init__.py b/lib/ansible/runner/__init__.py
index 1755879..d305a38 100644
--- a/lib/ansible/runner/__init__.py
+++ b/lib/ansible/runner/__init__.py
@@ -411,6 +411,7 @@ class Runner(object):
inject = utils.combine_vars(inject, self.module_vars)
inject = utils.combine_vars(inject, self.setup_cache[host])
inject.setdefault('ansible_ssh_user', self.remote_user)
+ inject.setdefault('ansible_connection', host_connection)
inject['hostvars'] = HostVars(self.setup_cache, self.inventory)
Timothys-MacBook-Pro:ansible-test tgerla$ tree
.
├── roles
│   └── myrole
│   └── tasks
│   └── main.yml
├── templates
│   └── mytemplate.j2
└── test-roles.yml
@tgerla
tgerla / gist:7269228
Created November 1, 2013 17:56
Test to see if selinux is enabled.
---
- hosts: all
tasks:
# this task runs 'getenforce' and registers the result into the "sestatus" variable
# changed_when: false tells ansible never to mark this task as "changed"
- name: test to see if selinux is running
command: getenforce
- name: my thing
command: this might fail or whatever
failed_when: false
register: testcommand
Timothys-MacBook-Pro:ansible-test tgerla$ ansible-playbook -i localhost, test-includes.yml -e myvar=this
PLAY [localhost] **************************************************************
GATHERING FACTS ***************************************************************
ok: [localhost]
TASK: [debug msg=hi] **********************************************************
skipping: [localhost]