From e0447b8a6dabcb43712004cd2291f795b21f6b8a Mon Sep 17 00:00:00 2001 From: Ryan Yates Date: Sat, 23 Sep 2017 11:42:49 -0400 Subject: [PATCH] ansible 2.x fixes (#4) Change sudo to become Added Debian 9(stretch) ignore errors on removing local known_hosts --- handlers/main.yml | 2 ++ meta/main.yml | 12 +++++------- tasks/ssh.yml | 5 ++++- vars/Debian-9.yml | 3 +++ 4 files changed, 14 insertions(+), 8 deletions(-) create mode 100644 vars/Debian-9.yml diff --git a/handlers/main.yml b/handlers/main.yml index 5fc7b18..ff7849f 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -1,6 +1,8 @@ --- - name: gen ssh keys command: ssh-keygen -A + become: true - name: restart ssh service: name={{ssh_service_name}} state=restarted + become: true diff --git a/meta/main.yml b/meta/main.yml index 072058c..682da2a 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -1,27 +1,25 @@ --- galaxy_info: author: Ryan Yates - description: Role for managing ntp. + description: Role for managing ssh. company: license: license (Apache 2.0) - min_ansible_version: 1.5 + min_ansible_version: 2.2 platforms: - name: Ubuntu versions: - precise - trusty + - xenial - name: Debian versions: - - squeeze - wheezy + - jessie + - stretch - name: EL versions: - 6 - 7 - - name: Fedora - versions: - - 19 - - 20 categories: - system dependencies: [] diff --git a/tasks/ssh.yml b/tasks/ssh.yml index 409377e..b71aa89 100644 --- a/tasks/ssh.yml +++ b/tasks/ssh.yml @@ -14,10 +14,13 @@ owner=root group=root mode=0600 + become: true notify: - gen ssh keys - restart ssh +# Ignore errors on this as it isn't reliable - name: Attempt to remove pub key from local known_hosts local_action: command ssh-keygen -f "$HOME/.ssh/known_hosts" -R hostname - sudo: no + become: false + ignore_errors: true diff --git a/vars/Debian-9.yml b/vars/Debian-9.yml new file mode 100644 index 0000000..98896bd --- /dev/null +++ b/vars/Debian-9.yml @@ -0,0 +1,3 @@ +--- +ssh_service_name: ssh +sshd_config_file: sshd_config.j2