From 0703f57b42c82f20caeaa6f9341a0b5cb6f68fcf Mon Sep 17 00:00:00 2001 From: cs171027 Date: Mon, 8 Jun 2020 19:13:01 +0300 Subject: [PATCH] Updates --- ansible.cfg | 2 -- ansible_provisioning.sh | 2 +- inventory/hosts | 4 ++-- roles/lxc_swarm/tasks/lxc_nodes.yml | 9 ++++++++- roles/lxc_swarm/tasks/main.yml | 2 +- 5 files changed, 12 insertions(+), 7 deletions(-) delete mode 100644 ansible.cfg diff --git a/ansible.cfg b/ansible.cfg deleted file mode 100644 index c4e5d88..0000000 --- a/ansible.cfg +++ /dev/null @@ -1,2 +0,0 @@ -[all:vars] -ansible_ssh_common_args='-o StrictHostKeyChecking=no -o userknownhostsfile=/dev/null' diff --git a/ansible_provisioning.sh b/ansible_provisioning.sh index 9b3d260..ccc00e4 100755 --- a/ansible_provisioning.sh +++ b/ansible_provisioning.sh @@ -1,4 +1,4 @@ #!/bin/bash [ `id -u` -ne 0 ] && exit 1 -test -f ~/.ssh/id_rsa.pub || ssh-keygen -t rsa -b 4096 -N '' -f ~/.ssh/id_rsa +test -f /root/.ssh/id_rsa.pub || ssh-keygen -t rsa -b 4096 -N '' -f /root/.ssh/id_rsa ansible-playbook -i inventory/hosts --skip-tags swarm --diff -v stack.yml diff --git a/inventory/hosts b/inventory/hosts index a4e1b11..c324184 100644 --- a/inventory/hosts +++ b/inventory/hosts @@ -2,7 +2,7 @@ 127.0.0.1 ansible_connection=local [workers] -10.0.3.100 ansible_ssh_user=root ansible_ssh_common_args='-o StrictHostKeyChecking=no' -10.0.3.101 ansible_ssh_user=root ansible_ssh_common_args='-o StrictHostKeyChecking=no' +10.0.3.100 ansible_ssh_user=root +10.0.3.101 ansible_ssh_user=root #For more workers add here the extra configuration #10.0.3.102 ansible_ssh_user=root diff --git a/roles/lxc_swarm/tasks/lxc_nodes.yml b/roles/lxc_swarm/tasks/lxc_nodes.yml index 2c12c65..a1ad096 100644 --- a/roles/lxc_swarm/tasks/lxc_nodes.yml +++ b/roles/lxc_swarm/tasks/lxc_nodes.yml @@ -25,8 +25,15 @@ - "worker2" tags: lxc +- name: Remove old container identification keys + shell: ssh-keygen -f /root/.ssh/known_hosts -R {{ item }} + with_items: + - "10.0.3.100" + - "10.0.3.101" + when: inventory_hostname in groups['manager'] + - name: Ensure container key is up-to-date locally - shell: ssh-keyscan {{ item }} >> ~/.ssh/known_hosts + shell: ssh-keyscan {{ item }} >> /root/.ssh/known_hosts with_items: - "10.0.3.100" - "10.0.3.101" diff --git a/roles/lxc_swarm/tasks/main.yml b/roles/lxc_swarm/tasks/main.yml index cc85ad5..dc9cdfe 100644 --- a/roles/lxc_swarm/tasks/main.yml +++ b/roles/lxc_swarm/tasks/main.yml @@ -2,7 +2,7 @@ # tasks file for roles/galera_swarm - name: Load in local SSH key path set_fact: - my_ssh_key: "{{ lookup('env','HOME') }}/.ssh/id_rsa.pub" + my_ssh_key: "/root/.ssh/id_rsa.pub" when: inventory_hostname in groups['manager'] tags: lxc