From 7b005fd1ecc8f031ff13cf4227e112b2c42f4b2d Mon Sep 17 00:00:00 2001 From: Markos Chandras Date: Wed, 14 Sep 2016 16:38:02 +0100 Subject: [PATCH] bifrost-prepare-for-test-dynamic: Create known_hosts if it's not present Create an empty ~/.ssh/known_hosts if it's not present since the subsequent commands assume that there is one in place. Fixes the following problem: fatal: [testvm1]: FAILED! => {"changed": true, "cmd": ["ssh-keygen", "-R", "192.168.122.3"], "delta": "0:00:00.004327", "end": "2016-09-14 08:26:42.448637", "failed": true, "invocation": {"module_args": {"_raw_params": "ssh- keygen -R \"192.168.122.3\"", "_uses_shell": false, "chdir": null, "creates": null, "executable": null, "removes": null, "warn": true}, "module_name": "command"}, "rc": 255, "start": "2016-09-14 08:26:42.444310", "stderr": "ssh-keygen: $ root/.ssh/known_hosts: No such file or directory", "stdout": "", "stdout_lines": [], "warnings": []} Change-Id: I0f05fb9aad7e7b9021491aac4d809ffc6fd4e864 --- .../roles/bifrost-prepare-for-test-dynamic/tasks/main.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/playbooks/roles/bifrost-prepare-for-test-dynamic/tasks/main.yml b/playbooks/roles/bifrost-prepare-for-test-dynamic/tasks/main.yml index 76ae43caa..abc4242e0 100644 --- a/playbooks/roles/bifrost-prepare-for-test-dynamic/tasks/main.yml +++ b/playbooks/roles/bifrost-prepare-for-test-dynamic/tasks/main.yml @@ -25,6 +25,12 @@ add_host: name="{{ hostvars[item]['ipv4_address'] }}:22" groups=test with_items: "{{ groups['baremetal'] }}" when: ipv4_address is defined +- name: "Ensure ~/.ssh/known_hosts is present" + file: + path: "~/.ssh/known_hosts" + state: touch + mode: 0600 + when: ipv4_address is defined - name: "Remove testvm hosts from SSH known_hosts file." command: ssh-keygen -R "{{ ipv4_address }}" when: ipv4_address is defined