diff --git a/tasks/main.yml b/tasks/main.yml index 90e9c0ab..1206bc8c 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -13,6 +13,23 @@ # See the License for the specific language governing permissions and # limitations under the License. +- name: Check for the presence of a public key file on the host + stat: + path: /root/.ssh/id_rsa.pub + register: _ssh_key + when: lxc_container_ssh_key is undefined + tags: + - always + +- name: Fail if a ssh public key is not set in a var and not present on the host + fail: + msg: "Please set the lxc_container_ssh_key variable or ensure that the host has the file /root/.ssh/id_rsa.pub present." + when: + - lxc_container_ssh_key is undefined + - not _ssh_key.stat.exists + tags: + - always + - name: Gather variables for each operating system include_vars: "{{ item }}" with_first_found: