From 737ca7b9965f7c44b3e032372a76d57844990e3a Mon Sep 17 00:00:00 2001 From: Hadrien Patte Date: Sat, 23 Mar 2019 19:25:04 +0100 Subject: [PATCH] Feat: add state Signed-off-by: Hadrien Patte --- roles/basesecurity/tasks/main.yml | 2 ++ roles/codimd/tasks/0_apt_dependencies.yml | 8 ++++++-- roles/dokuwiki/tasks/main.yml | 3 ++- roles/etherpad/tasks/main.yml | 3 ++- roles/ldap-client/tasks/0_install_ldap.yml | 3 ++- roles/ldap-client/tasks/1_group_security.yml | 3 +++ roles/matrix-mxisd/tasks/main.yml | 1 + roles/matrix-riot/tasks/main.yml | 9 +++++++-- roles/matrix-synapse/tasks/main.yml | 3 ++- roles/nginx-reverse-proxy/tasks/main.yml | 3 ++- roles/nodejs/tasks/main.yml | 3 ++- 11 files changed, 31 insertions(+), 10 deletions(-) diff --git a/roles/basesecurity/tasks/main.yml b/roles/basesecurity/tasks/main.yml index a08b869..6ff69e8 100644 --- a/roles/basesecurity/tasks/main.yml +++ b/roles/basesecurity/tasks/main.yml @@ -42,6 +42,7 @@ - name: Install fail2ban apt: name: fail2ban + state: present register: apt_result retries: 3 until: apt_result is succeeded @@ -79,6 +80,7 @@ - name: Install debsums apt: name: debsums + state: present register: apt_result retries: 3 until: apt_result is succeeded diff --git a/roles/codimd/tasks/0_apt_dependencies.yml b/roles/codimd/tasks/0_apt_dependencies.yml index 76646e6..c698390 100644 --- a/roles/codimd/tasks/0_apt_dependencies.yml +++ b/roles/codimd/tasks/0_apt_dependencies.yml @@ -2,8 +2,9 @@ # For HTTPS apt - name: Install HTTPS apt apt: - name: apt-transport-https update_cache: true + name: apt-transport-https + state: present register: apt_result retries: 3 until: apt_result is succeeded @@ -12,6 +13,7 @@ apt_key: url: https://dl.yarnpkg.com/debian/pubkey.gpg id: 1646B01B86E50310 + state: present register: apt_key_result retries: 3 until: apt_key_result is succeeded @@ -19,12 +21,14 @@ - name: Configure Yarn repository apt_repository: repo: deb https://dl.yarnpkg.com/debian/ stable main + state: present # Install CodiMD dependencies - name: Install required packages apt: - name: yarn update_cache: true + name: yarn + state: present register: apt_result retries: 3 until: apt_result is succeeded diff --git a/roles/dokuwiki/tasks/main.yml b/roles/dokuwiki/tasks/main.yml index 4e1722f..76321ba 100644 --- a/roles/dokuwiki/tasks/main.yml +++ b/roles/dokuwiki/tasks/main.yml @@ -22,8 +22,9 @@ # Install - name: Install DokuWiki apt: - name: dokuwiki update_cache: true + name: dokuwiki + state: present register: apt_result retries: 3 until: apt_result is succeeded diff --git a/roles/etherpad/tasks/main.yml b/roles/etherpad/tasks/main.yml index ab5e3b1..21667ec 100644 --- a/roles/etherpad/tasks/main.yml +++ b/roles/etherpad/tasks/main.yml @@ -2,8 +2,9 @@ # Install EtherPad dependencies - name: Install required packages apt: - name: curl update_cache: true + name: curl + state: present register: apt_result retries: 3 until: apt_result is succeeded diff --git a/roles/ldap-client/tasks/0_install_ldap.yml b/roles/ldap-client/tasks/0_install_ldap.yml index 5905d4a..31665cc 100644 --- a/roles/ldap-client/tasks/0_install_ldap.yml +++ b/roles/ldap-client/tasks/0_install_ldap.yml @@ -2,11 +2,12 @@ # Install LDAP client packages - name: Install LDAP client packages apt: + update_cache: true name: - nslcd - libnss-ldapd - libpam-ldapd - update_cache: true + state: present register: apt_result retries: 3 until: apt_result is succeeded diff --git a/roles/ldap-client/tasks/1_group_security.yml b/roles/ldap-client/tasks/1_group_security.yml index d9bf2cb..607dce7 100644 --- a/roles/ldap-client/tasks/1_group_security.yml +++ b/roles/ldap-client/tasks/1_group_security.yml @@ -5,6 +5,7 @@ dest: /etc/ssh/sshd_config regexp: ^AllowGroups line: AllowGroups root sudoldap aurore ssh + state: present # To gain root access with ldap rights - name: Install SUDO package @@ -21,6 +22,7 @@ dest: /etc/sudoers regexp: ^%{{ sudo_group }} line: "%{{ sudo_group }} ALL=(ALL:ALL) ALL" + state: present # Set sudo location group - name: Configure sudoers sudo location group @@ -28,4 +30,5 @@ dest: /etc/sudoers regexp: ^%{{ sudo_group_location }} line: "%{{ sudo_group_location }} ALL=(ALL:ALL) ALL" + state: present when: sudo_group_location is defined diff --git a/roles/matrix-mxisd/tasks/main.yml b/roles/matrix-mxisd/tasks/main.yml index 422243f..ad40117 100644 --- a/roles/matrix-mxisd/tasks/main.yml +++ b/roles/matrix-mxisd/tasks/main.yml @@ -2,6 +2,7 @@ - name: Install mxisd apt: deb: "{{ mxisd_deb }}" + state: present register: apt_result retries: 3 until: apt_result is succeeded diff --git a/roles/matrix-riot/tasks/main.yml b/roles/matrix-riot/tasks/main.yml index 8b83ef1..2214777 100644 --- a/roles/matrix-riot/tasks/main.yml +++ b/roles/matrix-riot/tasks/main.yml @@ -2,8 +2,9 @@ # Install HTTPS support for APT - name: Install apt-transport-https apt: - name: apt-transport-https update_cache: true + name: apt-transport-https + state: present register: apt_result retries: 3 until: apt_result is succeeded @@ -12,12 +13,14 @@ - name: Configure riot repository apt_repository: repo: deb https://riot.im/packages/debian/ {{ ansible_distribution_release }} main + state: present # Add the key - name: Configure the apt key apt_key: url: https://riot.im/packages/debian/repo-key.asc id: E019645248E8F4A1 + state: present register: apt_key_result retries: 3 until: apt_key_result is succeeded @@ -25,8 +28,9 @@ # Install riot - name: Install riot-web apt: - name: riot-web update_cache: true + name: riot-web + state: present register: apt_result retries: 3 until: apt_result is succeeded @@ -35,6 +39,7 @@ - name: Install nginx apt: name: nginx + state: present register: apt_result retries: 3 until: apt_result is succeeded diff --git a/roles/matrix-synapse/tasks/main.yml b/roles/matrix-synapse/tasks/main.yml index 196611f..91b66c8 100644 --- a/roles/matrix-synapse/tasks/main.yml +++ b/roles/matrix-synapse/tasks/main.yml @@ -1,8 +1,9 @@ --- - name: Install matrix-synapse apt: - name: matrix-synapse update_cache: true + name: matrix-synapse + state: present default_release: stretch-backports register: apt_result retries: 3 diff --git a/roles/nginx-reverse-proxy/tasks/main.yml b/roles/nginx-reverse-proxy/tasks/main.yml index a570a9f..aac1af3 100644 --- a/roles/nginx-reverse-proxy/tasks/main.yml +++ b/roles/nginx-reverse-proxy/tasks/main.yml @@ -4,8 +4,9 @@ # but also reduces the surface of attack - name: Install NGINX server apt: - name: nginx-light update_cache: true + name: nginx-light + state: present register: apt_result retries: 3 until: apt_result is succeeded diff --git a/roles/nodejs/tasks/main.yml b/roles/nodejs/tasks/main.yml index af8fe52..0f17fa8 100644 --- a/roles/nodejs/tasks/main.yml +++ b/roles/nodejs/tasks/main.yml @@ -10,11 +10,12 @@ - name: Install required packages apt: + update_cache: true name: - nodejs - npm - build-essential # To build npm packages - update_cache: true + state: present register: apt_result retries: 3 until: apt_result is succeeded