From 1b32be19c07a01d57dd44543070ae55118c54f24 Mon Sep 17 00:00:00 2001 From: Jeremy Lecour Date: Sat, 12 Aug 2017 11:39:33 -0400 Subject: [PATCH 01/30] mysql script directory is a variable --- mysql/tasks/utils.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mysql/tasks/utils.yml b/mysql/tasks/utils.yml index 262dcd0f..eafb9068 100644 --- a/mysql/tasks/utils.yml +++ b/mysql/tasks/utils.yml @@ -1,8 +1,8 @@ --- -- name: Ensure /usr/share/scripts exists +- name: Ensure scripts directory exists file: - dest: /usr/share/scripts + dest: "{{ mysql_scripts_dir or general_scripts_dir | mandatory }}" mode: "0700" state: directory tags: From 213ad5a606ce942f1fa98f46243ce33b9463fa34 Mon Sep 17 00:00:00 2001 From: Jeremy Lecour Date: Sat, 12 Aug 2017 12:10:21 -0400 Subject: [PATCH 02/30] mysql: log2mail config is owned by log2mail group --- mysql/tasks/log2mail.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mysql/tasks/log2mail.yml b/mysql/tasks/log2mail.yml index fb256d26..568b6649 100644 --- a/mysql/tasks/log2mail.yml +++ b/mysql/tasks/log2mail.yml @@ -13,6 +13,8 @@ template: src: log2mail.j2 dest: /etc/log2mail/config/mysql.conf + owner: log2mail + group: adm mode: "0640" when: log2mail_config_dir.stat.exists tags: From a8570456614a82b4cb430393cbc87f041fba22e1 Mon Sep 17 00:00:00 2001 From: Jeremy Lecour Date: Sat, 12 Aug 2017 12:11:13 -0400 Subject: [PATCH 03/30] mysql: use apg for passwords --- mysql/tasks/nrpe.yml | 2 +- mysql/tasks/users_jessie.yml | 2 +- mysql/tasks/users_stretch.yml | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mysql/tasks/nrpe.yml b/mysql/tasks/nrpe.yml index 7cebcf50..be18a966 100644 --- a/mysql/tasks/nrpe.yml +++ b/mysql/tasks/nrpe.yml @@ -20,7 +20,7 @@ - block: - name: Create a password for NRPE - shell: perl -e 'print map{("a".."z","A".."Z",0..9)[int(rand(62))]}(1..16)' + command: "apg -n 1 -m 16 -M lcN" register: mysql_nrpe_password changed_when: False diff --git a/mysql/tasks/users_jessie.yml b/mysql/tasks/users_jessie.yml index 4d225317..a8c22cf8 100644 --- a/mysql/tasks/users_jessie.yml +++ b/mysql/tasks/users_jessie.yml @@ -10,7 +10,7 @@ - mysql - name: create a password for mysqladmin - shell: perl -e 'print map{("a".."z","A".."Z",0..9)[int(rand(62))]}(1..16)' + command: "apg -n 1 -m 16 -M lcN" register: mysql_admin_password changed_when: False tags: diff --git a/mysql/tasks/users_stretch.yml b/mysql/tasks/users_stretch.yml index 0a3238eb..c57bd3ae 100644 --- a/mysql/tasks/users_stretch.yml +++ b/mysql/tasks/users_stretch.yml @@ -10,7 +10,7 @@ - mysql - name: create a password for mysqladmin - shell: perl -e 'print map{("a".."z","A".."Z",0..9)[int(rand(62))]}(1..16)' + command: "apg -n 1 -m 16 -M lcN" register: mysql_admin_password changed_when: False tags: @@ -45,7 +45,7 @@ - name: create a password for debian-sys-maint - shell: perl -e 'print map{("a".."z","A".."Z",0..9)[int(rand(62))]}(1..16)' + command: "apg -n 1 -m 16 -M lcN" register: mysql_debian_password changed_when: False tags: From 7d8c1988490ba1fa90f0a4ab257c5bec547edbda Mon Sep 17 00:00:00 2001 From: Jeremy Lecour Date: Sat, 12 Aug 2017 12:13:35 -0400 Subject: [PATCH 04/30] mysql: split packages tasks by release --- mysql/tasks/main.yml | 6 ++- .../{packages.yml => packages_jessie.yml} | 0 mysql/tasks/packages_stretch.yml | 37 +++++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) rename mysql/tasks/{packages.yml => packages_jessie.yml} (100%) create mode 100644 mysql/tasks/packages_stretch.yml diff --git a/mysql/tasks/main.yml b/mysql/tasks/main.yml index ca3f0571..be64360c 100644 --- a/mysql/tasks/main.yml +++ b/mysql/tasks/main.yml @@ -1,6 +1,10 @@ --- -- include: packages.yml +- include: packages_stretch.yml + when: ansible_distribution_release == "stretch" + +- include: packages_jessie.yml + when: ansible_distribution_release == "jessie" - include: users_stretch.yml when: ansible_distribution_release == "stretch" diff --git a/mysql/tasks/packages.yml b/mysql/tasks/packages_jessie.yml similarity index 100% rename from mysql/tasks/packages.yml rename to mysql/tasks/packages_jessie.yml diff --git a/mysql/tasks/packages_stretch.yml b/mysql/tasks/packages_stretch.yml new file mode 100644 index 00000000..d5645bea --- /dev/null +++ b/mysql/tasks/packages_stretch.yml @@ -0,0 +1,37 @@ +--- + +- name: Choose packages + set_fact: + mysql_packages: "{{ item }}" + with_items: + - mariadb-server + - mariadb-client + tags: + - mysql + - packages + +- name: Install MySQL packages + apt: + name: '{{ item }}' + update_cache: yes + state: present + with_items: "{{ mysql_packages }}" + tags: + - mysql + - packages + +- name: MySQL is started + service: + name: mysql + state: started + tags: + - mysql + - services + +- name: apg package is installed + apt: + name: apg + state: present + tags: + - mysql + - packages From 574cf3ab44a26227a776676b7954b07ecb532bb1 Mon Sep 17 00:00:00 2001 From: Jeremy Lecour Date: Sat, 12 Aug 2017 12:23:44 -0400 Subject: [PATCH 05/30] mysql: install mysqltuner from packages --- mysql/tasks/utils.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/mysql/tasks/utils.yml b/mysql/tasks/utils.yml index eafb9068..20b62581 100644 --- a/mysql/tasks/utils.yml +++ b/mysql/tasks/utils.yml @@ -52,13 +52,17 @@ when: (mysql_scripts_dir or general_scripts_dir) | search ("/usr") - name: Install mysqltuner - copy: - src: mysqltuner.pl - dest: "{{ mysql_scripts_dir or general_scripts_dir | mandatory }}/mysqltuner.pl" - mode: "0700" + # copy: + # src: mysqltuner.pl + # dest: "{{ mysql_scripts_dir or general_scripts_dir | mandatory }}/mysqltuner.pl" + # mode: "0700" + apt: + name: mysqltuner + state: present tags: - mysql - mysqltuner + - mysqltuner - name: Install aha apt: From d15bcc168e25a49c708a320880fa87b45d9857f5 Mon Sep 17 00:00:00 2001 From: Jeremy Lecour Date: Sat, 12 Aug 2017 12:24:14 -0400 Subject: [PATCH 06/30] mysql: fix mysql optimize tasks --- mysql/tasks/utils.yml | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/mysql/tasks/utils.yml b/mysql/tasks/utils.yml index 20b62581..7fae0c97 100644 --- a/mysql/tasks/utils.yml +++ b/mysql/tasks/utils.yml @@ -83,7 +83,7 @@ tags: - mysql -- name: "Cron dir is present" +- name: "Cron dir for optimize is present" file: path: "/etc/cron.{{ mysql_cron_optimize_frequency | mandatory }}" state: directory @@ -102,12 +102,36 @@ - name: "Disable cron to optimize MySQL" file: - dest: /etc/cron.weekly/mysql-optimize.sh + dest: /etc/cron.{{ mysql_cron_optimize_frequency | mandatory }}/mysql-optimize.sh state: absent when: not mysql_cron_optimize tags: - mysql +- name: "Cron dir for mysqltuner is present" + file: + path: "/etc/cron.{{ mysql_cron_mysqltuner_frequency | mandatory }}" + state: directory + mode: "0755" + owner: root + group: root + +- name: "Enable mysqltuner in cron" + copy: + src: mysqltuner.cron.sh + dest: /etc/cron.{{ mysql_cron_mysqltuner_frequency | mandatory }}/mysqltuner.sh + when: mysql_cron_mysqltuner + tags: + - mysql + +- name: "Disable mysqltuner in cron" + file: + dest: /etc/cron.{{ mysql_cron_mysqltuner_frequency | mandatory }}/mysqltuner.sh + state: absent + when: not mysql_cron_mysqltuner + tags: + - mysql + # my-add.sh - include: remount_usr_rw.yml From efa7e288dd48581759e1b000ab23b28026c4db70 Mon Sep 17 00:00:00 2001 From: Jeremy Lecour Date: Sat, 12 Aug 2017 12:25:07 -0400 Subject: [PATCH 07/30] mysql: install cron task for mysqltuer --- mysql/defaults/main.yml | 3 ++ mysql/files/mysqltuner.cron.sh | 50 ++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 mysql/files/mysqltuner.cron.sh diff --git a/mysql/defaults/main.yml b/mysql/defaults/main.yml index 3c2bbeb6..b84e59ec 100644 --- a/mysql/defaults/main.yml +++ b/mysql/defaults/main.yml @@ -18,4 +18,7 @@ mysql_innodb_buffer_pool_size: '{{ (ansible_memtotal_mb * 0.3) | int }}M' mysql_cron_optimize: True mysql_cron_optimize_frequency: weekly +mysql_cron_mysqltuner: True +mysql_cron_mysqltuner_frequency: monthly + mysql_force_new_nrpe_password: False diff --git a/mysql/files/mysqltuner.cron.sh b/mysql/files/mysqltuner.cron.sh new file mode 100644 index 00000000..5424aa90 --- /dev/null +++ b/mysql/files/mysqltuner.cron.sh @@ -0,0 +1,50 @@ +#!/bin/bash +set -e +export TERM=screen + +mem=$(free -m | grep Mem: | tr -s ' ' | cut -d ' ' -f2) +swap=$(free -m | grep Swap: | tr -s ' ' | cut -d ' ' -f2) +template=$(mktemp --tmpdir=/tmp evomysqltuner.XXX) +body=$(mktemp --tmpdir=/tmp evomysqltuner.XXX) +clientmail=$(grep EVOMAINTMAIL /etc/evomaintenance.cf | cut -d'=' -f2) +hostname=$(grep HOSTNAME /etc/evomaintenance.cf | cut -d'=' -f2) +hostname=${hostname%%.evolix.net} +# If hostname is composed with -, remove the first part. +if [[ $hostname =~ "-" ]]; then + hostname=$(echo $hostname | cut -d'-' -f2-) +fi + +# Remove temporary files on exit. +trap "rm $template $body" EXIT + +# Add port here if you have more than one instance! +instances="3306" +for instance in $instances; do + mysqltuner --port $instance --host 127.0.0.1 --forcemem $mem --forceswap $swap \ + | aha > /var/www/mysqlreport_${instance}.html + cat << EOT > $template +Content-Type: text/plain; charset="utf-8" +Reply-To: Équipe Evolix +From: Équipe Evolix +To: $clientmail +Subject: Rapport MySQL instance $instance pour votre serveur $hostname +EOT + cat << EOT > $body +Bonjour, + +Veuillez trouver ci-joint un rapport MySQL. +Celui-ci permet d'identifier aisément si des optimisations MySQL sont possibles. + +N'hésitez pas à nous indiquer par mail ou ticket quelles variables vous souhaiter +optimiser. + +Veuillez noter qu'il faudra redémarrer MySQL pour appliquer de nouveaux paramètres. + +Bien à vous, +-- +Rapport automatique Evolix +EOT + mutt -x -e 'set send_charset="utf-8"' -H $template \ + -a /var/www/mysqlreport_${instance}.html < $body +done +chmod 644 /var/www/mysqlreport*html From 69ed3ecf05cff425a4b3e8c261bc6202a7cd152a Mon Sep 17 00:00:00 2001 From: Jeremy Lecour Date: Sat, 12 Aug 2017 12:35:37 -0400 Subject: [PATCH 08/30] apache: fix log2mail config permissions --- apache/tasks/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apache/tasks/main.yml b/apache/tasks/main.yml index 2c919a41..f503d9b3 100644 --- a/apache/tasks/main.yml +++ b/apache/tasks/main.yml @@ -148,8 +148,8 @@ template: src: log2mail-apache.j2 dest: "/etc/log2mail/config/apache" - owner: root - group: root + owner: log2mail + group: adm mode: "0644" force: no From a4b917152d40400009bd4a56a811dbbad13c5ac8 Mon Sep 17 00:00:00 2001 From: Jeremy Lecour Date: Sat, 12 Aug 2017 12:51:15 -0400 Subject: [PATCH 09/30] apache: cleanup munin tasks --- apache/defaults/main.yml | 2 ++ apache/handlers/main.yml | 5 +++++ apache/tasks/main.yml | 3 +++ apache/tasks/munin.yml | 23 +++++++++++++++++++++++ 4 files changed, 33 insertions(+) create mode 100644 apache/tasks/munin.yml diff --git a/apache/defaults/main.yml b/apache/defaults/main.yml index 810a0676..d7d5fb25 100644 --- a/apache/defaults/main.yml +++ b/apache/defaults/main.yml @@ -13,5 +13,7 @@ apache_phpmyadmin_set: False apache_phpmyadmin_suffix: "" apache_serverstatus_suffix: "" +apache_munin_include: True + general_alert_email: "root@localhost" log2mail_alert_email: Null diff --git a/apache/handlers/main.yml b/apache/handlers/main.yml index af4d94d2..09fa8b02 100644 --- a/apache/handlers/main.yml +++ b/apache/handlers/main.yml @@ -8,3 +8,8 @@ service: name: apache2 state: reloaded + +- name: reload munin-node + service: + name: munin-node + state: reloaded diff --git a/apache/tasks/main.yml b/apache/tasks/main.yml index f503d9b3..3ba54c7e 100644 --- a/apache/tasks/main.yml +++ b/apache/tasks/main.yml @@ -169,3 +169,6 @@ # dest: /var/www/index.html # regexp: '__SERVERSTATUS_SUFFIX__' # replace: "{{ apache_serverstatus_suffix }}" + +- include: munin.yml + when: apache_munin_include diff --git a/apache/tasks/munin.yml b/apache/tasks/munin.yml new file mode 100644 index 00000000..85f0b386 --- /dev/null +++ b/apache/tasks/munin.yml @@ -0,0 +1,23 @@ +--- + +- name: munin-node and core plugins are installed + apt: + name: "{{ item }}" + state: installed + with_items: + - munin-node + - munin-plugins-core + +- name: enable munin plugins + file: + src: "/usr/share/munin/plugins/{{ item }}" + dest: "/etc/munin/plugins/{{ item }}" + state: link + with_items: + - apache_accesses + - apache_processes + - apache_volume + notify: restart munin-node + tags: + - apache + - munin From 17bdfc8fef199e59e34e3bed232f5aa829d39d49 Mon Sep 17 00:00:00 2001 From: Jeremy Lecour Date: Sat, 12 Aug 2017 12:51:28 -0400 Subject: [PATCH 10/30] apache: cleanup log2mail tasks --- apache/defaults/main.yml | 1 + apache/tasks/log2mail.yml | 15 +++++++++++++++ apache/tasks/main.yml | 16 +++------------- 3 files changed, 19 insertions(+), 13 deletions(-) create mode 100644 apache/tasks/log2mail.yml diff --git a/apache/defaults/main.yml b/apache/defaults/main.yml index d7d5fb25..6b28d670 100644 --- a/apache/defaults/main.yml +++ b/apache/defaults/main.yml @@ -13,6 +13,7 @@ apache_phpmyadmin_set: False apache_phpmyadmin_suffix: "" apache_serverstatus_suffix: "" +apache_log2mail_include: True apache_munin_include: True general_alert_email: "root@localhost" diff --git a/apache/tasks/log2mail.yml b/apache/tasks/log2mail.yml new file mode 100644 index 00000000..894ff039 --- /dev/null +++ b/apache/tasks/log2mail.yml @@ -0,0 +1,15 @@ +--- + +- name: log2mail is installed + apt: + name: log2mail + state: present + +- name: Add log2mail config for Apache segfaults + template: + src: log2mail-apache.j2 + dest: "/etc/log2mail/config/apache" + owner: log2mail + group: adm + mode: "0644" + force: no diff --git a/apache/tasks/main.yml b/apache/tasks/main.yml index 3ba54c7e..a3ff8cfd 100644 --- a/apache/tasks/main.yml +++ b/apache/tasks/main.yml @@ -139,19 +139,6 @@ - include: phpmyadmin.yml when: apache_phpmyadmin_set and _default_index.stat.exists -- name: Check if log2mail is installed - apt: - name: log2mail - state: present - -- name: Add log2mail config for Apache segfaults - template: - src: log2mail-apache.j2 - dest: "/etc/log2mail/config/apache" - owner: log2mail - group: adm - mode: "0644" - force: no # - block: # - name: generate random string for serverstatus suffix @@ -170,5 +157,8 @@ # regexp: '__SERVERSTATUS_SUFFIX__' # replace: "{{ apache_serverstatus_suffix }}" +- include: log2mail.yml + when: apache_log2mail_include + - include: munin.yml when: apache_munin_include From 1896e531cbf35ef68a4830b02c9866313919c1fe Mon Sep 17 00:00:00 2001 From: Jeremy Lecour Date: Sat, 12 Aug 2017 15:45:54 -0400 Subject: [PATCH 11/30] evoadmin: use variables in template --- evoadmin/defaults/main.yml | 10 ++++++++++ evoadmin/templates/web-mail.tpl.j2 | 28 ++++++++++++++-------------- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/evoadmin/defaults/main.yml b/evoadmin/defaults/main.yml index 35cdcb6c..cdf309a3 100644 --- a/evoadmin/defaults/main.yml +++ b/evoadmin/defaults/main.yml @@ -12,3 +12,13 @@ evoadmin_username: evoadmin evoadmin_ssl_subject: "/CN={{ evoadmin_host }}" evoadmin_enable_vhost: True + +evoadmin_tpl_servername: "{{ ansible_fqdn }}" +evoadmin_tpl_address: "{{ ansible_default_ipv4.address }}" +evoadmin_tpl_phpmyadmin_url: Null +evoadmin_tpl_cgi_suffix: Null +evoadmin_tpl_signature: evoadmin +evoadmin_tpl_mail_from: root@localhost +evoadmin_tpl_mail_bcc: Null +evoadmin_tpl_mail_standard: "{{ general_alert_email }}" +evoadmin_tpl_mail_urgent: "{{ general_alert_email }}" diff --git a/evoadmin/templates/web-mail.tpl.j2 b/evoadmin/templates/web-mail.tpl.j2 index 82d4f67d..262995c3 100644 --- a/evoadmin/templates/web-mail.tpl.j2 +++ b/evoadmin/templates/web-mail.tpl.j2 @@ -1,6 +1,6 @@ -From: %MAIL_FROM% +From: {{ evoadmin_tpl_mail_from }} To: RCPTTO -Bcc: %MAIL_BCC% +Bcc: {{ evoadmin_tpl_mail_bcc }} Subject: Parametres hebergement web : LOGIN Bonjour, @@ -11,7 +11,7 @@ Votre compte d'hebergement web a ete cree. * CONNEXION SFTP/SSH ********************************** -NOM DU SERVEUR : %SERVER_NAME% +NOM DU SERVEUR : {{ evoadmin_tpl_servername }} USER : LOGIN PASSWORD : PASSE1 @@ -20,10 +20,10 @@ PASSWORD : PASSE1 ***************************************** URL du site : -http://SERVERNAME +http://{{ evoadmin_tpl_servername }} URL des stats : -http://SERVERNAME/cgi-RANDOM/awstats.pl +http://{{ evoadmin_tpl_servername }}/cgi-RANDOM/awstats.pl (acces par IP ou login a demander !) Repertoire de connexion : HOME_DIR/LOGIN/ @@ -47,20 +47,20 @@ USER : LOGIN PASSWORD : PASSE2 NOM BASE : DBNAME URL interface d'admin : -%PMA_URL% +{{ evoadmin_tpl_phpmyadmin_url }} *********************************** * Rappels divers *********************************** Votre nom de domaine doit etre configure pour pointer -sur l'adresse IP %SERVER_ADDR% (enregistrement DNS A) -ou etre un alias de %SERVER_NAME% (enregistrement DNS CNAME). +sur l'adresse IP {{ evoadmin_tpl_address }} (enregistrement DNS A) +ou etre un alias de {{ evoadmin_tpl_servername }} (enregistrement DNS CNAME). Si vous avez besoin de faire des tests, vous devez ajouter la ligne suivante au fichier "/etc/hosts" sous Linux/Unix ou au fichier "system32\drivers\etc\hosts" sous Windows NT/XP : -%SERVER_ADDR% SERVERNAME +{{ evoadmin_tpl_address }} {{ evoadmin_tpl_servername }} Attention, par defaut, toutes les connexions vers l'exterieur sont bloquees. Si vous avez besoin de recuperer des donnees @@ -71,16 +71,16 @@ Afin de securiser au maximum le serveur, certaines URL particulieres sont non autorisees pour eviter diverses attaques (XSS, robots, trojans, injections, etc.). Exemple d'URL refusee : -http://SERVERNAME/cmd32.exe +http://{{ evoadmin_tpl_servername }}/cmd32.exe En cas de soucis avec votre application, prevenez-nous. Si vous desirez mettre en place des parametres particuliers -pour votre site (PHP, etc.) ou pour tout autre demande (scripts en crontab, +pour votre site (PHP, etc.) ou pour tout autre demande (scripts en crontab, etc.), n'hesitez pas a nous contacter a l'adresse -%MAIL_STANDARD% (ou %MAIL_URGENT% si votre demande est +{{ evoadmin_tpl_mail_standard }} (ou {{ evoadmin_tpl_mail_urgent }} si votre demande est urgente). Cordialement, --- -%FOOTER% \ No newline at end of file +-- +{{ evoadmin_tpl_signature }} From 3b68fe074f4a6cc5c480cd2df055b6fd8bf93645 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Lecour?= Date: Mon, 14 Aug 2017 12:51:15 +0200 Subject: [PATCH 12/30] Install, contributions and workflow documentation --- README.md | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/README.md b/README.md index f8a280c8..c5ca1fef 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,56 @@ A repository for Ansible roles used by Evolix. It contains only roles, everything else is available at https://forge.evolix.org/projects/ansible-public +## Branches + The **stable** branch contains roles that we consider ready for production. The **unstable** branch contains not sufficiently tested roles (or evolutions on existing roles) that we don't consider ready for production yet. + +Many feature branches may exist in the repository. They represent "work in progress". They may be used, for testing purposes. + +## Install and usage + +First, check-out the repository : + +``` +$ cd ~/GIT/ +$ git clone https://forge.evolix.org/projects/ansible-roles +``` + +Then, add its path to your ansible load path : + +``` +$ vim ~/.ansible.cfg +[defaults] +roles_path = $HOME/GIT/ansible-roles +``` + +Then, include roles in your playbooks : + +``` +- hosts: all + gather_facts: yes + become: yes + roles: + - etc-git + - evolinux-base +``` + +## Contributing + +Contributions are welcome, especially bug fixes and "ansible good practices". They will be merged in if they are consistent with our conventions and use cases. They might be rejected if they introduce complexity, cover features we don't need or don't fit "style". + +Before starting anything of importance, we suggest contacting us to discuss what you'd like to add or change. + +Our conventions are available in the "ansible-public":https://forge.evolix.org/projects/ansible-public repository, in the CONVENTIONS.md file. + +## Workflow + +The ideal and most typical workflow is to create a branch, based on the "unstable" branch. The branch should have a descriptive name (a ticket/issue number is great). The branch can be treated as a pull-request or merge-request. It should be propery tested and reviewed before merging into "unstable". + +Changes that don't introduce significant changes — or that must go faster that the typical workflow — can be commited directly into "unstable". + +Hotfixes, can be prepared on a new branch, based on "stable" or "unstable" (to be decided by the author). When ready, it can be merged back to "stable" for immediate deployment and to "unstable" for proper backporting. + +Other workflow are not forbidden, but should be discussed in advance. From 29e1c3053f69f83b18d97205c01d461953e70c3f Mon Sep 17 00:00:00 2001 From: Romain Dessort Date: Mon, 14 Aug 2017 11:03:21 -0400 Subject: [PATCH 13/30] TMOUT is now set in /etc/profile.d/evolinux.sh --- evocheck/files/evocheck.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/evocheck/files/evocheck.sh b/evocheck/files/evocheck.sh index b972d8be..1f5262e9 100644 --- a/evocheck/files/evocheck.sh +++ b/evocheck/files/evocheck.sh @@ -220,7 +220,7 @@ if [ -e /etc/debian_version ]; then fi if [ "$IS_TMOUTPROFILE" = 1 ]; then - grep -q TMOUT= /etc/profile || echo 'IS_TMOUTPROFILE FAILED!' + grep -q TMOUT= /etc/profile /etc/profile.d/evolinux.sh || echo 'IS_TMOUTPROFILE FAILED!' fi if [ "$IS_ALERT5BOOT" = 1 ]; then From 48b4238a88fc563c6944e87fe53f892c24ad3207 Mon Sep 17 00:00:00 2001 From: Romain Dessort Date: Mon, 14 Aug 2017 11:06:12 -0400 Subject: [PATCH 14/30] Make git commit task not to fail if user.email is undefined --- etc-git/tasks/commit.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/etc-git/tasks/commit.yml b/etc-git/tasks/commit.yml index 31746443..3d0562c9 100644 --- a/etc-git/tasks/commit.yml +++ b/etc-git/tasks/commit.yml @@ -22,10 +22,11 @@ repo: /etc scope: local register: git_config_user_email + ignore_errors: yes - name: set commit author set_fact: - etc_git_commit_options: "{% if ansible_env.SUDO_USER %} --author \"{{ ansible_env.SUDO_USER }} <{{ git_config_user_email.config_value }}>\"{% endif %}" + etc_git_commit_options: "{% if ansible_env.SUDO_USER %} --author \"{{ ansible_env.SUDO_USER }} <{{ git_config_user_email.config_value |default()}}>\"{% endif %}" - name: /etc modifications are committed shell: "git add -A . && git commit -m \"{{ commit_message | mandatory }}\"{{ etc_git_commit_options }}" From 94223e54a0369f0f372b4ad792d4c030f21f4843 Mon Sep 17 00:00:00 2001 From: Romain Dessort Date: Mon, 14 Aug 2017 11:17:59 -0400 Subject: [PATCH 15/30] apt-listchanges is not installed anymore --- evocheck/files/evocheck.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/evocheck/files/evocheck.sh b/evocheck/files/evocheck.sh index 1f5262e9..4c08b930 100644 --- a/evocheck/files/evocheck.sh +++ b/evocheck/files/evocheck.sh @@ -204,7 +204,7 @@ if [ -e /etc/debian_version ]; then fi if [ "$IS_LISTCHANGESCONF" = 1 ]; then - egrep "(which=both|confirm=1)" /etc/apt/listchanges.conf | wc -l | grep -q ^2$ || echo 'IS_LISTCHANGESCONF FAILED!' + is_debianversion stretch || ( test -e /etc/apt/listchanges.conf && egrep "(which=both|confirm=1)" /etc/apt/listchanges.conf | wc -l | grep -q ^2$ || echo 'IS_LISTCHANGESCONF FAILED!' ) fi if [ "$IS_CUSTOMCRONTAB" = 1 ]; then From 35198325c4e9ebefcbbeaf5b0278c23536da2a89 Mon Sep 17 00:00:00 2001 From: Gregory Colpart Date: Thu, 17 Aug 2017 14:47:37 +0200 Subject: [PATCH 16/30] Verify if login exists --- admin-users/tasks/user.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/admin-users/tasks/user.yml b/admin-users/tasks/user.yml index 7de5b778..b36f6eb6 100644 --- a/admin-users/tasks/user.yml +++ b/admin-users/tasks/user.yml @@ -1,5 +1,12 @@ --- +- name: "Test if '{{ user.name }}' exists" + command: 'getent passwd {{ user.name }}' + register: loginisbusy + failed_when: False + changed_when: False + check_mode: no + - name: "Test if uid exists for '{{ user.name }}'" command: 'getent passwd {{ user.uid }}' register: uidisbusy @@ -16,7 +23,7 @@ shell: /bin/bash password: '{{ user.password_hash }}' update_password: on_create - when: uidisbusy.rc != 0 + when: loginisbusy.rc != 0 and uidisbusy.rc != 0 - name: "Add Unix account with random uid for '{{ user.name }}'" user: @@ -26,7 +33,7 @@ shell: /bin/bash password: '{{ user.password_hash }}' update_password: on_create - when: uidisbusy.rc == 0 + when: loginisbusy.rc != 0 and uidisbusy.rc == 0 - name: "Create {{ admin_users_group }}" group: From 463ae9750858d7f851090be01654025254c022a9 Mon Sep 17 00:00:00 2001 From: Gregory Colpart Date: Thu, 17 Aug 2017 14:50:34 +0200 Subject: [PATCH 17/30] proftpd role : add TimesGMT option to off to conform to https://wiki.evolix.org/HowtoProFTPD (thanks to jdubois) --- proftpd/templates/evolinux.conf.j2 | 1 + 1 file changed, 1 insertion(+) diff --git a/proftpd/templates/evolinux.conf.j2 b/proftpd/templates/evolinux.conf.j2 index 2b62e1c0..d6e8b565 100644 --- a/proftpd/templates/evolinux.conf.j2 +++ b/proftpd/templates/evolinux.conf.j2 @@ -14,6 +14,7 @@ MaxClientsPerHost 20 PassivePorts 60000 61000 UseReverseDNS off IdentLookups off +TimesGMT off # Local permissions DefaultRoot ~ From e5e44d5bc1b91acb3ba460b79956d37e8111206f Mon Sep 17 00:00:00 2001 From: Gregory Colpart Date: Fri, 18 Aug 2017 02:31:41 +0200 Subject: [PATCH 18/30] standard Evolix name is /etc/apache2/ipaddr_whitelist.conf cf https://wiki.evolix.org/HowtoApache --- apache/tasks/auth.yml | 10 ++++----- apache/templates/evolinux-default.conf.j2 | 26 +++++++++++------------ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/apache/tasks/auth.yml b/apache/tasks/auth.yml index 32b9966a..0f550a3c 100644 --- a/apache/tasks/auth.yml +++ b/apache/tasks/auth.yml @@ -1,9 +1,9 @@ --- -- name: Init private_ipaddr_whitelist.conf file +- name: Init ipaddr_whitelist.conf file copy: src: private_ipaddr_whitelist.conf - dest: /etc/apache2/private_ipaddr_whitelist.conf + dest: /etc/apache2/ipaddr_whitelist.conf owner: root group: root mode: "0640" @@ -13,7 +13,7 @@ - name: add IP addresses to private IP whitelist lineinfile: - dest: /etc/apache2/private_ipaddr_whitelist.conf + dest: /etc/apache2/ipaddr_whitelist.conf line: "Require ip {{ item }}" state: present with_items: "{{ apache_private_ipaddr_whitelist_present }}" @@ -23,7 +23,7 @@ - name: remove IP addresses from private IP whitelist lineinfile: - dest: /etc/apache2/private_ipaddr_whitelist.conf + dest: /etc/apache2/ipaddr_whitelist.conf line: "Require ip {{ item }}" state: absent with_items: "{{ apache_private_ipaddr_whitelist_absent }}" @@ -34,7 +34,7 @@ - name: include private IP whitelist for server-status lineinfile: dest: /etc/apache2/mods-available/status.conf - line: " include /etc/apache2/private_ipaddr_whitelist.conf" + line: " include /etc/apache2/ipaddr_whitelist.conf" insertafter: 'SetHandler server-status' state: present tags: diff --git a/apache/templates/evolinux-default.conf.j2 b/apache/templates/evolinux-default.conf.j2 index a1f681e4..a53d3c9f 100644 --- a/apache/templates/evolinux-default.conf.j2 +++ b/apache/templates/evolinux-default.conf.j2 @@ -5,24 +5,24 @@ DocumentRoot /var/www/ - Include /etc/apache2/private_ipaddr_whitelist.conf + Include /etc/apache2/ipaddr_whitelist.conf Options -Indexes Require all denied - Include /etc/apache2/private_ipaddr_whitelist.conf + Include /etc/apache2/ipaddr_whitelist.conf # Munin. We need to set Directory directive as Alias take precedence. Alias /munin /var/cache/munin/www Require all denied - Include /etc/apache2/private_ipaddr_whitelist.conf + Include /etc/apache2/ipaddr_whitelist.conf Options -Indexes Require all denied - Include /etc/apache2/private_ipaddr_whitelist.conf + Include /etc/apache2/ipaddr_whitelist.conf # For CGI Scripts. We need to set Directory directive as ScriptAlias take precedence. @@ -30,7 +30,7 @@ Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Require all denied - Include /etc/apache2/private_ipaddr_whitelist.conf + Include /etc/apache2/ipaddr_whitelist.conf CustomLog /var/log/apache2/access.log vhost_combined @@ -53,7 +53,7 @@ SetHandler server-status - include /etc/apache2/private_ipaddr_whitelist.conf + include /etc/apache2/ipaddr_whitelist.conf Require local @@ -68,12 +68,12 @@ DocumentRoot /var/www/ - Include /etc/apache2/private_ipaddr_whitelist.conf + Include /etc/apache2/ipaddr_whitelist.conf Options -Indexes Require all denied - Include /etc/apache2/private_ipaddr_whitelist.conf + Include /etc/apache2/ipaddr_whitelist.conf SSLEngine on @@ -83,19 +83,19 @@ # We override these 2 Directory directives setted in apache2.conf. # We want no access except from allowed IP address. - Include /etc/apache2/private_ipaddr_whitelist.conf + Include /etc/apache2/ipaddr_whitelist.conf # Munin. We need to set Directory directive as Alias take precedence. Alias /munin /var/cache/munin/www Require all denied - Include /etc/apache2/private_ipaddr_whitelist.conf + Include /etc/apache2/ipaddr_whitelist.conf Options -Indexes Require all denied - Include /etc/apache2/private_ipaddr_whitelist.conf + Include /etc/apache2/ipaddr_whitelist.conf # For CGI Scripts. We need to set Directory directive as ScriptAlias take precedence. @@ -103,7 +103,7 @@ Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Require all denied - Include /etc/apache2/private_ipaddr_whitelist.conf + Include /etc/apache2/ipaddr_whitelist.conf CustomLog /var/log/apache2/access.log vhost_combined @@ -113,7 +113,7 @@ SetHandler server-status - include /etc/apache2/private_ipaddr_whitelist.conf + include /etc/apache2/ipaddr_whitelist.conf Require local From bcd333aaa9cdd063b8c82cbccd556c881a679ab1 Mon Sep 17 00:00:00 2001 From: Gregory Colpart Date: Fri, 18 Aug 2017 02:58:26 +0200 Subject: [PATCH 19/30] ansible-roles is now only-Linux compatible, and add precision for compatibility (Debian 9 and accidentally Debian 8) --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c5ca1fef..966c4a70 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # Ansible-roles -A repository for Ansible roles used by Evolix. +A repository for Ansible roles used by Evolix on Debian GNU/Linux 9 (stretch) servers. +Few roles are also be compatible with Debian GNU/Linux 8 (jessie) servers. It contains only roles, everything else is available at https://forge.evolix.org/projects/ansible-public From 2bb7367edfdf863a8b90734f6e848c10a7d153e2 Mon Sep 17 00:00:00 2001 From: Gregory Colpart Date: Fri, 18 Aug 2017 03:31:46 +0200 Subject: [PATCH 20/30] standardization for Debian versions : we use "jessie" or "9 or later" to prepare buster smoothly as possible --- admin-users/tasks/sudo.yml | 2 +- admin-users/tasks/user.yml | 4 ++-- apache/tasks/main.yml | 4 ++-- evoacme/tasks/certbot.yml | 2 +- evoadmin/tasks/web.yml | 2 +- evolinux-base/tasks/packages.yml | 5 ++++- jenkins/tasks/main.yml | 4 ++-- mongodb/tasks/main.yml | 4 ++-- mysql/tasks/main.yml | 4 ++-- newrelic/tasks/sources.yml | 4 ++-- nginx/tasks/main_regular.yml | 2 +- packweb-apache/tasks/main.yml | 2 +- php-fpm/tasks/main.yml | 8 ++++++-- 13 files changed, 27 insertions(+), 20 deletions(-) diff --git a/admin-users/tasks/sudo.yml b/admin-users/tasks/sudo.yml index 793e67d5..f8daf81f 100644 --- a/admin-users/tasks/sudo.yml +++ b/admin-users/tasks/sudo.yml @@ -22,5 +22,5 @@ validate: '/usr/sbin/visudo -cf %s' when: - ansible_distribution == "Debian" - - ansible_distribution_major_version | version_compare('9', '<') + - ansible_distribution_release == "jessie" - not copy_sudoers_evolinux.changed diff --git a/admin-users/tasks/user.yml b/admin-users/tasks/user.yml index b36f6eb6..ba72b388 100644 --- a/admin-users/tasks/user.yml +++ b/admin-users/tasks/user.yml @@ -39,12 +39,12 @@ group: name: "{{ admin_users_group }}" -- name: "Add user to sudo group (Stretch)" +- name: "Add user to sudo group (Debian 9 or later)" user: name: '{{ user.name }}' groups: 'sudo,{{ admin_users_group }}' append: yes - when: ansible_distribution_release == "stretch" + when: ansible_distribution_major_version | version_compare('9', '>=') - name: "Fix perms on homedirectory for '{{ user.name }}'" file: diff --git a/apache/tasks/main.yml b/apache/tasks/main.yml index a3ff8cfd..c9d60dc5 100644 --- a/apache/tasks/main.yml +++ b/apache/tasks/main.yml @@ -1,6 +1,6 @@ --- -- name: packages are installed (stretch) +- name: packages are installed (Debian 9 or later) apt: name: '{{ item }}' state: present @@ -13,7 +13,7 @@ tags: - apache - packages - when: ansible_distribution_release == "stretch" + when: ansible_distribution_major_version | version_compare('9', '>=') - name: packages are installed (jessie) apt: diff --git a/evoacme/tasks/certbot.yml b/evoacme/tasks/certbot.yml index eae7ba86..526fbb07 100644 --- a/evoacme/tasks/certbot.yml +++ b/evoacme/tasks/certbot.yml @@ -65,7 +65,7 @@ squid_service_name: squid3 when: - ansible_distribution == "Debian" - - ansible_distribution_major_version | version_compare('9', '<') + - ansible_distribution_release == "jessie" - name: Let's Encrypt OCSP server is authorized by squid lineinfile: diff --git a/evoadmin/tasks/web.yml b/evoadmin/tasks/web.yml index 7cf6c9d2..87237248 100644 --- a/evoadmin/tasks/web.yml +++ b/evoadmin/tasks/web.yml @@ -16,7 +16,7 @@ option: "disable_functions" value: "shell-exec,system,passthru,putenv,popen" notify: reload apache - when: ansible_distribution_release == "stretch" + when: ansible_distribution_major_version | version_compare('9', '>=') - name: Install evoadmin VHost template: diff --git a/evolinux-base/tasks/packages.yml b/evolinux-base/tasks/packages.yml index 399f3f8f..b8c6576a 100644 --- a/evolinux-base/tasks/packages.yml +++ b/evolinux-base/tasks/packages.yml @@ -109,6 +109,9 @@ with_items: - { option: "confirm", value: "1" } - { option: "which", value: "both" } - when: evolinux_packages_listchanges and ansible_distribution == "Debian" and ansible_distribution_major_version | version_compare('9', '<') + when: + - evolinux_packages_listchanges + - ansible_distribution == "Debian" + - ansible_distribution_release == "jessie" - meta: flush_handlers diff --git a/jenkins/tasks/main.yml b/jenkins/tasks/main.yml index 70f6771d..83d3ec92 100644 --- a/jenkins/tasks/main.yml +++ b/jenkins/tasks/main.yml @@ -11,12 +11,12 @@ check_mode: no register: squid_whitelist_files -- name: set squid_service_name=squid3 for Debian < 9 +- name: set squid_service_name=squid3 for Debian 8 set_fact: squid_service_name: squid3 when: - ansible_distribution == "Debian" - - ansible_distribution_major_version | version_compare('9', '<') + - ansible_distribution_release == "jessie" - name: Append packages.dotdeb.org to Squid whitelist lineinfile: diff --git a/mongodb/tasks/main.yml b/mongodb/tasks/main.yml index f659df2d..f222c799 100644 --- a/mongodb/tasks/main.yml +++ b/mongodb/tasks/main.yml @@ -7,12 +7,12 @@ check_mode: no register: squid_whitelist_files -- name: set squid_service_name=squid3 for Debian < 9 +- name: set squid_service_name=squid3 for Debian 8 set_fact: squid_service_name: squid3 when: - ansible_distribution == "Debian" - - ansible_distribution_major_version | version_compare('9', '<') + - ansible_distribution_release == "jessie" - name: Append packages.dotdeb.org to Squid whitelist lineinfile: diff --git a/mysql/tasks/main.yml b/mysql/tasks/main.yml index be64360c..d6892fef 100644 --- a/mysql/tasks/main.yml +++ b/mysql/tasks/main.yml @@ -1,13 +1,13 @@ --- - include: packages_stretch.yml - when: ansible_distribution_release == "stretch" + when: ansible_distribution_major_version | version_compare('9', '>=') - include: packages_jessie.yml when: ansible_distribution_release == "jessie" - include: users_stretch.yml - when: ansible_distribution_release == "stretch" + when: ansible_distribution_major_version | version_compare('9', '>=') - include: users_jessie.yml when: ansible_distribution_release == "jessie" diff --git a/newrelic/tasks/sources.yml b/newrelic/tasks/sources.yml index cdcf5dc2..551fc8b5 100644 --- a/newrelic/tasks/sources.yml +++ b/newrelic/tasks/sources.yml @@ -5,12 +5,12 @@ # url: https://download.newrelic.com/548C16BF.gpg data: "{{ lookup('file', '548C16BF.gpg') }}" -- name: set squid_service_name=squid3 for Debian < 9 +- name: set squid_service_name=squid3 for Debian 8 set_fact: squid_service_name: squid3 when: - ansible_distribution == "Debian" - - ansible_distribution_major_version | version_compare('9', '<') + - ansible_distribution_release == "jessie" - name: Find squid config whitelist shell: find /etc/{{ squid_service_name | default('squid') }}/whitelist-custom.conf /etc/{{ squid_service_name | default('squid') }}/whitelist.conf 2> /dev/null diff --git a/nginx/tasks/main_regular.yml b/nginx/tasks/main_regular.yml index bc58503b..74580972 100644 --- a/nginx/tasks/main_regular.yml +++ b/nginx/tasks/main_regular.yml @@ -4,7 +4,7 @@ when: ansible_distribution_release == "jessie" - include: packages_stretch.yml - when: ansible_distribution_release == "stretch" + when: ansible_distribution_major_version | version_compare('9', '>=') # TODO: find a way to override the main configuration # without touching the main file diff --git a/packweb-apache/tasks/main.yml b/packweb-apache/tasks/main.yml index 17e3909c..1aefaa7b 100644 --- a/packweb-apache/tasks/main.yml +++ b/packweb-apache/tasks/main.yml @@ -42,7 +42,7 @@ when: ansible_distribution_release == "jessie" - include: php.yml - when: ansible_distribution_release == "stretch" + when: ansible_distribution_major_version | version_compare('9', '>=') - include: phpmyadmin.yml diff --git a/php-fpm/tasks/main.yml b/php-fpm/tasks/main.yml index f05ae125..de12d1a7 100644 --- a/php-fpm/tasks/main.yml +++ b/php-fpm/tasks/main.yml @@ -2,7 +2,9 @@ apt: name: php5-fpm state: present - when: ansible_distribution_major_version | version_compare('8', '<=') + when: + - ansible_distribution == "Debian" + - ansible_distribution_release == "jessie" tags: - php-fpm @@ -10,6 +12,8 @@ apt: name: php-fpm state: present - when: ansible_distribution_major_version | version_compare('9', '>=') + when: + - ansible_distribution == "Debian" + - ansible_distribution_major_version | version_compare('9', '>=') tags: - php-fpm From d82b12b6146cade2945b672a8a7374c29810c837 Mon Sep 17 00:00:00 2001 From: Gregory Colpart Date: Fri, 18 Aug 2017 04:13:56 +0200 Subject: [PATCH 21/30] fail when evolinux_ssh_password_auth_addresses is empty instead of Ansible crash (like for minifirewall) --- evolinux-base/tasks/ssh.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/evolinux-base/tasks/ssh.yml b/evolinux-base/tasks/ssh.yml index 6f79c982..9326b13c 100644 --- a/evolinux-base/tasks/ssh.yml +++ b/evolinux-base/tasks/ssh.yml @@ -1,5 +1,9 @@ --- +- fail: + msg: You must provide at least 1 ssh trusted IP + when: evolinux_ssh_password_auth_addresses == [] + - name: Security directives for Evolinux blockinfile: dest: /etc/ssh/sshd_config From 2fd165a465868d6392591223a5f0361efc74eb07 Mon Sep 17 00:00:00 2001 From: Gregory Colpart Date: Fri, 18 Aug 2017 04:18:52 +0200 Subject: [PATCH 22/30] fix error in handler call --- apache/tasks/munin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apache/tasks/munin.yml b/apache/tasks/munin.yml index 85f0b386..42914d3e 100644 --- a/apache/tasks/munin.yml +++ b/apache/tasks/munin.yml @@ -17,7 +17,7 @@ - apache_accesses - apache_processes - apache_volume - notify: restart munin-node + notify: reload munin-node tags: - apache - munin From 8dbe8bf4ac237c7a5bfdb06adbe6e59ac4dd1f48 Mon Sep 17 00:00:00 2001 From: Gregory Colpart Date: Fri, 18 Aug 2017 05:05:17 +0200 Subject: [PATCH 23/30] Quick fix because MySQL install doesn't work anymore on Stretch --- mysql/tasks/packages_stretch.yml | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/mysql/tasks/packages_stretch.yml b/mysql/tasks/packages_stretch.yml index d5645bea..d625f691 100644 --- a/mysql/tasks/packages_stretch.yml +++ b/mysql/tasks/packages_stretch.yml @@ -1,21 +1,13 @@ --- -- name: Choose packages - set_fact: - mysql_packages: "{{ item }}" - with_items: - - mariadb-server - - mariadb-client - tags: - - mysql - - packages - - name: Install MySQL packages apt: name: '{{ item }}' update_cache: yes state: present - with_items: "{{ mysql_packages }}" + with_items: + - mariadb-server + - mariadb-client tags: - mysql - packages From a95d7893c50e86435f568dbd4705c5d81c3a38ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20S=C3=89RIE?= Date: Fri, 18 Aug 2017 14:37:18 +0200 Subject: [PATCH 24/30] Add a comment about AcceptEnv --- evolinux-base/tasks/ssh.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/evolinux-base/tasks/ssh.yml b/evolinux-base/tasks/ssh.yml index 9326b13c..b9cfd9e6 100644 --- a/evolinux-base/tasks/ssh.yml +++ b/evolinux-base/tasks/ssh.yml @@ -59,6 +59,8 @@ notify: reload sshd when: evolinux_ssh_disable_root +# We disable AcceptEnv because it can be a security issue, but also because we +# do not want clients to push their environment variables like LANG. - name: disable AcceptEnv in ssh config replace: dest: /etc/ssh/sshd_config From f0ced31efa202571fbecde85b0e52de9c3bee2d9 Mon Sep 17 00:00:00 2001 From: Gregory Colpart Date: Fri, 18 Aug 2017 15:18:06 +0200 Subject: [PATCH 25/30] review default vars --- apt/defaults/main.yml | 1 + munin/defaults/main.yml | 1 - munin/templates/munin.conf.j2 | 2 +- mysql/defaults/main.yml | 2 +- nagios-nrpe/defaults/main.yml | 2 +- 5 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apt/defaults/main.yml b/apt/defaults/main.yml index 671bc8b2..9e01a74e 100644 --- a/apt/defaults/main.yml +++ b/apt/defaults/main.yml @@ -1,3 +1,4 @@ +--- apt_install_basics: True apt_basics_components: "main" diff --git a/munin/defaults/main.yml b/munin/defaults/main.yml index 005a7989..ed97d539 100644 --- a/munin/defaults/main.yml +++ b/munin/defaults/main.yml @@ -1,2 +1 @@ --- -munin_dir: /home/www/munin diff --git a/munin/templates/munin.conf.j2 b/munin/templates/munin.conf.j2 index 6c837aa3..27e9c97e 100644 --- a/munin/templates/munin.conf.j2 +++ b/munin/templates/munin.conf.j2 @@ -6,7 +6,7 @@ # defaulted to the values you see here. # #dbdir /var/db/munin -htmldir {{ munin_dir }} +#htmldir /var/cache/munin/www #logdir /var/log/munin #rundir /var/run/munin diff --git a/mysql/defaults/main.yml b/mysql/defaults/main.yml index b84e59ec..d56e5999 100644 --- a/mysql/defaults/main.yml +++ b/mysql/defaults/main.yml @@ -2,7 +2,7 @@ general_alert_email: "root@localhost" log2mail_alert_email: Null -general_scripts_dir: "/usr/local/bin" +general_scripts_dir: "/usr/share/scripts" mysql_scripts_dir: Null mysql_variant: oracle diff --git a/nagios-nrpe/defaults/main.yml b/nagios-nrpe/defaults/main.yml index f1a4731b..c9ee2603 100644 --- a/nagios-nrpe/defaults/main.yml +++ b/nagios-nrpe/defaults/main.yml @@ -5,6 +5,6 @@ nagios_nrpe_ldap_passwd: LDAP_PASSWD nagios_nrpe_pgsql_passwd: PGSQL_PASSWD nagios_nrpe_amavis_from: "foobar@{{ ansible_domain }}" -nagios_nrpe_check_proxy_host: "www.debian.org" +nagios_nrpe_check_proxy_host: "www.example.com" nagios_plugins_directory: "/usr/local/lib/nagios/plugins" From ab08969cfb1097595c7519a6aab600023d180ff9 Mon Sep 17 00:00:00 2001 From: Gregory Colpart Date: Tue, 22 Aug 2017 00:29:29 +0200 Subject: [PATCH 26/30] We decided a new policy for sudo in stretch because our previous stretch policy is buggy --- admin-users/tasks/user.yml | 11 +++++++++-- admin-users/templates/sudoers_stretch.j2 | 3 ++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/admin-users/tasks/user.yml b/admin-users/tasks/user.yml index ba72b388..604af57c 100644 --- a/admin-users/tasks/user.yml +++ b/admin-users/tasks/user.yml @@ -35,14 +35,21 @@ update_password: on_create when: loginisbusy.rc != 0 and uidisbusy.rc == 0 -- name: "Create {{ admin_users_group }}" +- name: "Create evolinux-sudo group" + group: + name: evolinux-sudo + system: yes + when: ansible_distribution_major_version | version_compare('9', '>=') + +- name: "Create {{ admin_users_group }} group" group: name: "{{ admin_users_group }}" + when: ansible_distribution_major_version | version_compare('9', '>=') - name: "Add user to sudo group (Debian 9 or later)" user: name: '{{ user.name }}' - groups: 'sudo,{{ admin_users_group }}' + groups: 'evolinux-sudo,{{ admin_users_group }}' append: yes when: ansible_distribution_major_version | version_compare('9', '>=') diff --git a/admin-users/templates/sudoers_stretch.j2 b/admin-users/templates/sudoers_stretch.j2 index 5332395c..8de1bbc6 100644 --- a/admin-users/templates/sudoers_stretch.j2 +++ b/admin-users/templates/sudoers_stretch.j2 @@ -5,4 +5,5 @@ Cmnd_Alias MAINT = /usr/share/scripts/evomaintenance.sh, /usr/share/scripts nagios ALL = NOPASSWD: /usr/lib/nagios/plugins/check_procs nagios ALL = (clamav) NOPASSWD: /usr/bin/clamscan /tmp/safe.txt -%sudo ALL = NOPASSWD: MAINT +%evolinux-sudo ALL=(ALL:ALL) ALL +%evolinux-sudo ALL = NOPASSWD: MAINT From 606f3a14f5f8b5e50a705603ecbae15920d2909d Mon Sep 17 00:00:00 2001 From: Gregory Colpart Date: Tue, 22 Aug 2017 01:36:56 +0200 Subject: [PATCH 27/30] Move sudo stuff to sudo.yml --- admin-users/tasks/sudo.yml | 13 +++++++++++++ admin-users/tasks/user.yml | 13 ------------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/admin-users/tasks/sudo.yml b/admin-users/tasks/sudo.yml index f8daf81f..347a7f34 100644 --- a/admin-users/tasks/sudo.yml +++ b/admin-users/tasks/sudo.yml @@ -24,3 +24,16 @@ - ansible_distribution == "Debian" - ansible_distribution_release == "jessie" - not copy_sudoers_evolinux.changed + +- name: "Create evolinux-sudo group" + group: + name: evolinux-sudo + system: yes + when: ansible_distribution_major_version | version_compare('9', '>=') + +- name: "Add user to sudo group (Debian 9 or later)" + user: + name: '{{ user.name }}' + groups: 'evolinux-sudo,{{ admin_users_group }}' + append: yes + when: ansible_distribution_major_version | version_compare('9', '>=') diff --git a/admin-users/tasks/user.yml b/admin-users/tasks/user.yml index 604af57c..b0126ca8 100644 --- a/admin-users/tasks/user.yml +++ b/admin-users/tasks/user.yml @@ -35,24 +35,11 @@ update_password: on_create when: loginisbusy.rc != 0 and uidisbusy.rc == 0 -- name: "Create evolinux-sudo group" - group: - name: evolinux-sudo - system: yes - when: ansible_distribution_major_version | version_compare('9', '>=') - - name: "Create {{ admin_users_group }} group" group: name: "{{ admin_users_group }}" when: ansible_distribution_major_version | version_compare('9', '>=') -- name: "Add user to sudo group (Debian 9 or later)" - user: - name: '{{ user.name }}' - groups: 'evolinux-sudo,{{ admin_users_group }}' - append: yes - when: ansible_distribution_major_version | version_compare('9', '>=') - - name: "Fix perms on homedirectory for '{{ user.name }}'" file: name: '/home/{{ user.name }}' From 5226082db098267873f04ae5e48be43a7e4bac3a Mon Sep 17 00:00:00 2001 From: Gregory Colpart Date: Tue, 22 Aug 2017 00:42:14 +0200 Subject: [PATCH 28/30] evolinux-base and admin-users are only compatible Debian >=8, declare once in main.yml and that's all (will be probably generalized to others modules if needed) --- admin-users/meta/main.yml | 1 + admin-users/tasks/main.yml | 6 ++++++ admin-users/tasks/sudo.yml | 1 - evolinux-base/tasks/main.yml | 7 +++++++ evolinux-base/tasks/packages.yml | 2 -- evolinux-base/tasks/ssh.yml | 4 +--- 6 files changed, 15 insertions(+), 6 deletions(-) diff --git a/admin-users/meta/main.yml b/admin-users/meta/main.yml index 7779f782..006768d3 100644 --- a/admin-users/meta/main.yml +++ b/admin-users/meta/main.yml @@ -12,6 +12,7 @@ galaxy_info: - name: Debian versions: - jessie + - stretch dependencies: [] # List your role dependencies here, one per line. diff --git a/admin-users/tasks/main.yml b/admin-users/tasks/main.yml index c7eeaf39..420c1427 100644 --- a/admin-users/tasks/main.yml +++ b/admin-users/tasks/main.yml @@ -1,5 +1,11 @@ --- +- fail: + msg: only compatible with Debian >= 8 + when: + - ansible_distribution == "Debian" + - ansible_distribution_major_version | version_compare('8', '<') + - debug: msg: "Warning: empty 'admin_users' variable, tasks will be skipped!" when: admin_users == {} diff --git a/admin-users/tasks/sudo.yml b/admin-users/tasks/sudo.yml index 347a7f34..2587e6d5 100644 --- a/admin-users/tasks/sudo.yml +++ b/admin-users/tasks/sudo.yml @@ -21,7 +21,6 @@ replace: '\1,{{ user.name }}' validate: '/usr/sbin/visudo -cf %s' when: - - ansible_distribution == "Debian" - ansible_distribution_release == "jessie" - not copy_sudoers_evolinux.changed diff --git a/evolinux-base/tasks/main.yml b/evolinux-base/tasks/main.yml index 8514d7f0..1cc27278 100644 --- a/evolinux-base/tasks/main.yml +++ b/evolinux-base/tasks/main.yml @@ -1,4 +1,11 @@ --- + +- fail: + msg: only compatible with Debian >= 8 + when: + - ansible_distribution == "Debian" + - ansible_distribution_major_version | version_compare('8', '<') + - name: Hostname include: hostname.yml when: evolinux_hostname_include diff --git a/evolinux-base/tasks/packages.yml b/evolinux-base/tasks/packages.yml index b8c6576a..8089e397 100644 --- a/evolinux-base/tasks/packages.yml +++ b/evolinux-base/tasks/packages.yml @@ -79,7 +79,6 @@ - net-tools when: - evolinux_packages_stretch - - ansible_distribution == "Debian" - ansible_distribution_major_version | version_compare('9', '>=') - name: Customize logcheck recipient @@ -111,7 +110,6 @@ - { option: "which", value: "both" } when: - evolinux_packages_listchanges - - ansible_distribution == "Debian" - ansible_distribution_release == "jessie" - meta: flush_handlers diff --git a/evolinux-base/tasks/ssh.yml b/evolinux-base/tasks/ssh.yml index b9cfd9e6..f337f3ed 100644 --- a/evolinux-base/tasks/ssh.yml +++ b/evolinux-base/tasks/ssh.yml @@ -75,8 +75,6 @@ regexp: '^#?LogLevel [A-Z]+' replace: "LogLevel VERBOSE" notify: reload sshd - when: - - ansible_distribution == "Debian" - - ansible_distribution_major_version | version_compare('9', '>=') + when: ansible_distribution_major_version | version_compare('9', '>=') - meta: flush_handlers From bbdbd53cca747cccd5ec0c54492c021223dc753d Mon Sep 17 00:00:00 2001 From: Gregory Colpart Date: Tue, 22 Aug 2017 00:48:17 +0200 Subject: [PATCH 29/30] Avoid using vars not well defined in src file name AND be compatible with Debian 10 --- admin-users/tasks/sudo.yml | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/admin-users/tasks/sudo.yml b/admin-users/tasks/sudo.yml index 2587e6d5..49b9c71e 100644 --- a/admin-users/tasks/sudo.yml +++ b/admin-users/tasks/sudo.yml @@ -1,20 +1,30 @@ --- -- name: Verify Evolinux sudoers file presence +- name: "Verify Evolinux sudoers file presence (jessie)" template: - src: sudoers_{{ ansible_distribution_release }}.j2 + src: sudoers_jessie.j2 dest: /etc/sudoers.d/evolinux force: no validate: '/usr/sbin/visudo -cf %s' register: copy_sudoers_evolinux + when: ansible_distribution_release == "jessie" -- name: Verify Evolinux sudoers file permissions +- name: "Verify Evolinux sudoers file presence (Debian 9 or later)" + template: + src: sudoers_stretch.j2 + dest: /etc/sudoers.d/evolinux + force: no + validate: '/usr/sbin/visudo -cf %s' + register: copy_sudoers_evolinux + when: ansible_distribution_major_version | version_compare('9', '>=') + +- name: "Verify Evolinux sudoers file permissions" file: path: /etc/sudoers.d/evolinux mode: "0440" state: file -- name: "Add user in sudoers file for '{{ user.name }}'" +- name: "Add user in sudoers file for '{{ user.name }}' (jessie)" replace: dest: /etc/sudoers.d/evolinux regexp: '^(User_Alias\s+ADMINS\s+=((?!{{ user.name }}).)*)$' @@ -24,7 +34,7 @@ - ansible_distribution_release == "jessie" - not copy_sudoers_evolinux.changed -- name: "Create evolinux-sudo group" +- name: "Create evolinux-sudo group (Debian 9 or later)" group: name: evolinux-sudo system: yes From 2d17c60f39c8b0df0c1b1149bdb460e3e504b1e1 Mon Sep 17 00:00:00 2001 From: Gregory Colpart Date: Tue, 22 Aug 2017 02:58:38 +0200 Subject: [PATCH 30/30] continuation of new policy for sudo in Debian 9 --- admin-users/tasks/sudo.yml | 4 ++-- admin-users/tasks/user.yml | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/admin-users/tasks/sudo.yml b/admin-users/tasks/sudo.yml index 49b9c71e..e05ac614 100644 --- a/admin-users/tasks/sudo.yml +++ b/admin-users/tasks/sudo.yml @@ -40,9 +40,9 @@ system: yes when: ansible_distribution_major_version | version_compare('9', '>=') -- name: "Add user to sudo group (Debian 9 or later)" +- name: "Add user to evolinux-sudo group (Debian 9 or later)" user: name: '{{ user.name }}' - groups: 'evolinux-sudo,{{ admin_users_group }}' + groups: 'evolinux-sudo' append: yes when: ansible_distribution_major_version | version_compare('9', '>=') diff --git a/admin-users/tasks/user.yml b/admin-users/tasks/user.yml index b0126ca8..94f1a0c3 100644 --- a/admin-users/tasks/user.yml +++ b/admin-users/tasks/user.yml @@ -35,11 +35,18 @@ update_password: on_create when: loginisbusy.rc != 0 and uidisbusy.rc == 0 -- name: "Create {{ admin_users_group }} group" +- name: "Create {{ admin_users_group }} group (Debian 9 or later)" group: name: "{{ admin_users_group }}" when: ansible_distribution_major_version | version_compare('9', '>=') +- name: "Add user to {{ admin_users_group }} group (Debian 9 or later)" + user: + name: '{{ user.name }}' + groups: '{{ admin_users_group }}' + append: yes + when: ansible_distribution_major_version | version_compare('9', '>=') + - name: "Fix perms on homedirectory for '{{ user.name }}'" file: name: '/home/{{ user.name }}'