Skip to content

Instantly share code, notes, and snippets.

@tbielawa
Created February 29, 2012 21:47
Show Gist options
  • Save tbielawa/1944690 to your computer and use it in GitHub Desktop.
Save tbielawa/1944690 to your computer and use it in GitHub Desktop.
# This would be your top level "collector".
# It has a ".ans" extension so the application knows to apply special preprocessing rules to it.
# webroll-javaupdate.ans
include: roll-webservers.yaml
include: update-javaservers.yaml
# "include: path" isn't anything special in YAML except for a dictionary.
# It is easily human readable and looks like yaml which all the other scripts look like
# So why break consistency?
# When .ans file is found by ansible, it gets parsed, then loads and collects the referenced files
# Taboot has a "Scripts" object for this, to handle collections of yaml documents.
# Each document is represented as a TabootScript object
# roll-webservers.yaml
----
- pattern: 'www0*.int.foobar.com'
hosts: '/etc/ansible/hosts'
tasks:
- name: write the apache config file
action: template src=/srv/httpd.j2 dest=/etc/httpd/conf
notify:
- restart apache
handlers:
- name: restart apache
- action: service name=httpd state=restarted
# update-javaservers.yaml
# same code as above, because I don't grock playbook yet. Just pretend it does something with yum
----
- pattern: 'app0*.int.foobar.com'
hosts: '/etc/ansible/hosts'
tasks:
- name: Update all packages on these servers
action: template src=/srv/httpd.j2 dest=/etc/httpd/conf
notify:
- restart apache
handlers:
- name: restart apache
- action: service name=httpd state=restarted
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment