Skip to content

Instantly share code, notes, and snippets.

[vagrant@localhost ~]$ curl -O https://github.com/needim/noty/archive/v2.1.0.tar.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
119 119 119 119 0 0 218 0 --:--:-- --:--:-- --:--:-- 1025
[vagrant@localhost ~]$ tar zxvf v2.1.0.tar.gz
gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error is not recoverable: exiting now
[vagrant@localhost ~]$ file v2.1.0.tar.gz
---
- hosts: localhost
connection: local
vars:
- x: "{{ 'False'|bool }}"
tasks:
[webservers]
my-staging-webserver-1
my-staging-webserver-2
my-prod-webserver-1
my-prod-webserver-2
[staging]
my-staging-webserver-1
my-staging-webserver-2
- include: packages.yml
- include: config.yml
---
- hosts: all
vars:
cluster_interface: eth0
tasks:
- name: debug me
debug: msg="{{ hostvars[inventory_hostname]["ansible_" + cluster_interface]["ipv4"]["address"] }}"
---
- hosts: webserver1
gather_facts: false
vars:
create_command: 'echo -e \"FOO=bar\\necho hello" > /tmp/sh.sh'
tasks:
- name: create the shell script
raw: sh -c "{{create_command}}"
---
- hosts: all
vars:
testvar: helloo
tasks:
- name: debug me
debug: msg="{{ testvar }}"
@tgerla
tgerla / gist:6211136
Created August 12, 2013 14:11
Ansible logging example
2013-08-12 07:10:43,089 p=12814 u=root | /root/git/ansible/bin/ansible-playbook -i hosts test-when.yml
2013-08-12 07:10:43,089 p=12814 u=root |
2013-08-12 07:10:43,097 p=12814 u=root | PLAY [all] ********************************************************************
2013-08-12 07:10:43,097 p=12814 u=root | GATHERING FACTS ***************************************************************
2013-08-12 07:10:44,678 p=12814 u=root | ok: [webserver1]
2013-08-12 07:10:46,592 p=12814 u=root | fatal: [webserver2] => {'msg': 'FAILED: [Errno 113] No route to host', 'failed': True}
2013-08-12 07:10:46,606 p=12814 u=root | TASK: [hello] *****************************************************************
2013-08-12 07:10:46,657 p=12814 u=root | skipping: [webserver1]
2013-08-12 07:10:46,697 p=12814 u=root | PLAY RECAP ********************************************************************
2013-08-12 07:10:46,701 p=12814 u=root | to retry, use: --limit @/var/tmp/ansible/test-when.retry
---
- hosts: all
vars:
debug: True
tasks:
- name: get path
shell: "echo $PATH"
register: last_result
---
# This playbook deploys the whole application stack in this site.
# apply common configuration to all hosts
- hosts: all
roles:
- common
- hosts: dbservers
user: root