Created
April 18, 2018 13:45
-
-
Save amarao/37c6c815cc391384b495ef7827286435 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
- hosts: all | |
gather_facts: no | |
serial: 1 | |
tasks: | |
- name: Remove old facts | |
meta: clear_facts | |
- name: | |
set_fact: | |
host_v1: '{{ansible_ssh_host}}' | |
host_v2: '{{ansible_host}}' | |
tags: | |
- always | |
- name: Forcefully drop fact cache for host | |
local_action: file path=.facts/{{inventory_hostname}} state=absent | |
changed_when: True | |
- name: remove old server key | |
local_action: command ssh-keygen -R '{{host_v1}}' | |
failed_when: false | |
changed_when: True | |
- name: remove old server IP key | |
local_action: shell ssh-keygen -R `host {{host_v1}}|awk '{print $4}'` | |
failed_when: false | |
changed_when: True | |
- name: remove old server key | |
local_action: command ssh-keygen -R '{{host_v2}}' | |
failed_when: false | |
changed_when: True | |
- name: remove old server IP key | |
local_action: shell ssh-keygen -R `host {{host_v2}}|awk '{print $4}'` | |
failed_when: false | |
changed_when: True | |
- hosts: all | |
gather_facts: no | |
tasks: | |
- name: Remember sever key and install python | |
raw: test -x /usr/bin/python || sudo apt-get update && sudo apt-get -y install python | |
changed_when: True | |
vars: | |
ansible_ssh_extra_args: '-o StrictHostKeyChecking=no' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment