Skip to content

Instantly share code, notes, and snippets.

@tgerla
Last active August 29, 2015 14:07
Show Gist options
  • Save tgerla/1cee1381ba527f36b75f to your computer and use it in GitHub Desktop.
Save tgerla/1cee1381ba527f36b75f to your computer and use it in GitHub Desktop.
---
- hosts: all
gather_facts: false
tasks:
- name: test possible passwords
local_action: shell sshpass -p {{ item }} ssh {{ user }}@{{ inventory_hostname }} date
register: pastpass
ignore_errors: true
with_items:
- "{{ past_password_01 }}"
- "{{ past_password_02 }}"
- "{{ past_password_03 }}"
- "{{ past_password_04 }}"
- "{{ past_password_05 }}"
- set_fact: ansible_ssh_pass={{ item.item }}
with_items: pastpass.results
when: item.rc == 0
- name: test ping
ping:
register: pingResult
ignore_errors: true
- raw: yum install -y python-simplejson
when: pingResult|failed and "ansible requires a json module" in pingResult.msg
register: didChange
- local_action: shell echo {{inventory_hostname}} >> jsonfixed.log
when: didChange|changed
- name: ping again to verify
ping:
register: pingResult
- local_action: shell echo {{inventory_hostname}} >> ansibleready.log
when: pingResult|success
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment