Last active
July 14, 2016 16:51
-
-
Save droopy4096/72cabebf90ba76b009d128d7dd82eef2 to your computer and use it in GitHub Desktop.
This file contains 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
[pakiti] | |
mypakiti.stanford.edu | |
[report] | |
localhost ansible_connection=local ansible_become=False patch_priority=0 | |
[blacklist] | |
failedhost1.stanford.edu # Incorrect sudo password | |
failedhost2.stanford.edu # SyntaxError: probably due to installed simplejson being for a different python version; easy_install'ed simplejson which breaks things | |
This file contains 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: collect ansible facts | |
setup: | |
ignore_errors: True | |
register: setup_run | |
- name: set priority for broken_hosts | |
set_fact: patch_priority=0 | |
when: setup_run|failed | |
- name: collect facter facts | |
facter: | |
This file contains 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: collect pakiti hosts information | |
pakiti_list_servers: | |
register: pakiti_hostlist | |
- name: Add pakiti-provided hosts | |
add_host: name={{ item }} groups=pakiti_hosts | |
when: pakiti_hostlist.ansible_facts.hosts[item].age == 0 and not item in groups.blacklist | |
with_items: '{{ pakiti_hostlist.ansible_facts.hosts }}' | |
- name: Add pakiti-provided dead hosts | |
add_host: name={{ item }} groups=pakiti_dead_hosts | |
when: pakiti_hostlist.ansible_facts.hosts[item].age > 0 | |
with_items: '{{ pakiti_hostlist.ansible_facts.hosts }}' |
This file contains 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: generate the report | |
template: src=priority_report.j2 dest=reports/priority_report.txt |
This file contains 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
Alive hosts | |
=========== | |
{%+ for host in groups['pakiti_hosts'] %} | |
{%+ if hostvars[host] is defined %} | |
{%+ if hostvars[host].facter_patch_priority is defined %} | |
{{ host }} {{ hostvars[host].facter_patch_priority }} | |
{% else %} | |
{{ host }} NA | |
{% endif %} | |
{% endif %} | |
{% endfor %} | |
Dead hosts | |
========== | |
According to Pakiti those hosts are dead: | |
{%+ for host in groups['pakiti_dead_hosts'] %} | |
{{ host }} | |
{% endfor %} | |
Blacklisted hosts | |
================= | |
{%+ for host in groups['blacklist'] %} | |
{{ host }} | |
{% endfor %} |
This file contains 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: pakiti | |
gather_facts: False | |
roles: | |
- role: pakiti_db | |
- hosts: pakiti_hosts,!report | |
gather_facts: False | |
roles: | |
- role: common | |
- hosts: pakiti_hosts,!report | |
gather_facts: False | |
tasks: | |
- name: check facts | |
debug: msg={{ facter_patch_priority }} | |
ignore_errors: yes | |
when: facter_patch_priority is defined | |
- hosts: report | |
gather_facts: False | |
roles: | |
- role: priority_report |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment