Move /usr rw remount into remount-usr role

This commit is contained in:
Victor LABORIE 2017-11-07 12:18:02 +01:00
parent 37c1325c1a
commit 1c48df025c
31 changed files with 69 additions and 347 deletions

View File

@ -131,7 +131,10 @@
tags: tags:
- apache - apache
- include: remount_usr_rw.yml - include_role:
name: remount-usr
tags:
- apache
- name: "Install save_apache_status.sh" - name: "Install save_apache_status.sh"
copy: copy:

View File

@ -1,12 +0,0 @@
---
- name: update ansible_mounts facts
setup:
filter: ansible_mounts
- name: mount /usr in rw
command: mount -o remount,rw /usr
args:
warn: no
changed_when: false
when: item.mount == '/usr' and item.options | match(".*ro.*")
with_items: "{{ ansible_mounts }}"

View File

@ -8,23 +8,8 @@
tags: tags:
- drbd - drbd
- name: Check if /usr is a partition - include_role:
shell: "mount | grep 'on /usr type'" name: remount-usr
args:
warn: no
changed_when: False
failed_when: False
register: usr_partition
check_mode: no
tags:
- drbd
- name: Mount /usr in rw
command: mount -o remount,rw /usr
args:
warn: no
changed_when: False
when: usr_partition.rc == 0 and nagios_plugins_dir.stat.exists
tags: tags:
- drbd - drbd

View File

@ -20,22 +20,8 @@
name: certbot name: certbot
state: latest state: latest
- name: Check if /usr is a partition - include_role:
shell: "mount | grep 'on /usr type'" name: remount-usr
args:
warn: no
changed_when: False
failed_when: False
check_mode: no
register: usr_partition
- name: Mount /usr in rw
command: mount -o remount,rw /usr
args:
warn: no
changed_when: False
when: usr_partition.rc == 0
- name: Remove certbot symlink for apt install - name: Remove certbot symlink for apt install
file: file:

View File

@ -1,5 +1,6 @@
--- ---
- include: remount_usr_rw.yml - include_role:
name: remount-usr
when: evocheck_bin_dir | search ("/usr") when: evocheck_bin_dir | search ("/usr")
- name: Scripts dir is present - name: Scripts dir is present

View File

@ -1,19 +0,0 @@
---
- name: Get mount options for partitions
shell: "mount | grep 'on /usr type'"
args:
warn: no
register: mount
changed_when: False
failed_when: False
when: not ansible_check_mode
- name: Remount /usr if it is a partition and it is not mounted in rw
command: "mount -o remount,rw /usr"
when:
- not ansible_check_mode
- mount.rc == 0
- not mount.stdout_lines.0 | search("rw")
check_mode: yes
args:
warn: no

View File

@ -1,19 +0,0 @@
---
- name: Get mount options for partitions
shell: "mount | grep 'on /usr type'"
args:
warn: no
register: mount
changed_when: False
failed_when: False
when: not ansible_check_mode
- name: Remount /usr if it is a partition and it is not mounted in rw
command: "mount -o remount,rw /usr"
when:
- not ansible_check_mode
- mount.rc == 0
- not mount.stdout_lines.0 | search("rw")
check_mode: yes
args:
warn: no

View File

@ -33,7 +33,8 @@
# TODO : find a way to force the console-data configuration # TODO : find a way to force the console-data configuration
# non-interactively (like tzdata ↑) # non-interactively (like tzdata ↑)
- include: remount_usr_rw.yml - include_role:
name: remount-usr
- name: Ensure automagic vim conf is disabled - name: Ensure automagic vim conf is disabled
lineinfile: lineinfile:

View File

@ -59,31 +59,11 @@
when: filebeat_logstash_plugin and logstash_plugin.stat.exists when: filebeat_logstash_plugin and logstash_plugin.stat.exists
- block: - block:
- name: Check if /usr is a partition - include_role:
shell: "mount | grep 'on /usr type'" name: remount-usr
args:
warn: no
changed_when: False
failed_when: False
check_mode: no
register: usr_partition
- name: Mount /usr in rw
command: mount -o remount,rw /usr
args:
warn: no
changed_when: False
when: usr_partition.rc == 0
- name: Logstash plugin is installed - name: Logstash plugin is installed
command: /usr/share/logstash/bin/logstash-plugin install logstash-input-beats command: /usr/share/logstash/bin/logstash-plugin install logstash-input-beats
- name: /usr is remounted
command: mount -oremount /usr
args:
warn: no
changed_when: False
when: usr_partition.rc == 0
when: when:
- filebeat_logstash_plugin - filebeat_logstash_plugin
- logstash_plugin.stat.exists - logstash_plugin.stat.exists

View File

@ -1,5 +1,6 @@
--- ---
- include: remount_usr_rw.yml - include_role:
name: remount-usr
when: general_scripts_dir | search("/usr") when: general_scripts_dir | search("/usr")
- name: "copy generateldif.sh" - name: "copy generateldif.sh"

View File

@ -1,19 +0,0 @@
---
- name: Get mount options for partitions
shell: "mount | grep 'on /usr type'"
args:
warn: no
register: mount
changed_when: False
failed_when: False
when: not ansible_check_mode
- name: Remount /usr if it is a partition and it is not mounted in rw
command: "mount -o remount,rw /usr"
when:
- not ansible_check_mode
- mount.rc == 0
- not mount.stdout_lines.0 | search("rw")
check_mode: yes
args:
warn: no

View File

@ -58,10 +58,8 @@
when: not ansible_check_mode when: not ansible_check_mode
- block: - block:
- name: Remount /usr as writable - include_role:
command: "mount -o remount,rw /usr" name: remount-usr
args:
warn: no
- name: Move kibana optimize directory - name: Move kibana optimize directory
shell: "mv /usr/share/kibana/optimize /var/lib/kibana/optimize && ln -s /var/lib/kibana/optimize /usr/share/kibana/optimize" shell: "mv /usr/share/kibana/optimize /var/lib/kibana/optimize && ln -s /var/lib/kibana/optimize /usr/share/kibana/optimize"
@ -69,11 +67,5 @@
creates: /var/lib/kibana/optimize creates: /var/lib/kibana/optimize
notify: restart kibana notify: restart kibana
- name: Remount /usr as read-only
command: "mount -o remount /usr"
args:
warn: no
when: mount.rc == 0 and not mount.stdout_lines.0 | search("rw")
- include: proxy_nginx.yml - include: proxy_nginx.yml
when: kibana_proxy_nginx when: kibana_proxy_nginx

View File

@ -1,19 +0,0 @@
---
- name: Get mount options for partitions
shell: "mount | grep 'on /usr type'"
args:
warn: no
register: mount
changed_when: False
failed_when: False
when: not ansible_check_mode
- name: Remount /usr if it is a partition and it is not mounted in rw
command: "mount -o remount,rw /usr"
when:
- not ansible_check_mode
- mount.rc == 0
- not mount.stdout_lines.0 | search("rw")
check_mode: yes
args:
warn: no

View File

@ -5,21 +5,8 @@
- include: packages.yml - include: packages.yml
- name: Check if /usr is a partition - include_role:
shell: "mount | grep 'on /usr type'" name: remount-usr
args:
warn: no
changed_when: False
failed_when: False
check_mode: no
register: usr_partition
- name: Mount /usr in rw
command: mount -o remount,rw /usr
args:
warn: no
changed_when: False
when: usr_partition.rc == 0
- name: Copy add-vm script - name: Copy add-vm script
get_url: get_url:

View File

@ -1,19 +0,0 @@
---
- name: Get mount options for partitions
shell: "mount | grep 'on /usr type'"
args:
warn: no
register: mount
changed_when: False
failed_when: False
when: not ansible_check_mode
- name: Remount /usr if it is a partition and it is not mounted in rw
command: "mount -o remount,rw /usr"
when:
- not ansible_check_mode
- mount.rc == 0
- not mount.stdout_lines.0 | search("rw")
check_mode: yes
args:
warn: no

View File

@ -48,7 +48,8 @@
# mysqltuner # mysqltuner
- include: remount_usr_rw.yml - include_role:
name: remount-usr
when: (mysql_scripts_dir or general_scripts_dir) | search ("/usr") when: (mysql_scripts_dir or general_scripts_dir) | search ("/usr")
- name: Install mysqltuner - name: Install mysqltuner
@ -71,7 +72,8 @@
# automatic optimizations # automatic optimizations
- include: remount_usr_rw.yml - include_role:
name: remount-usr
when: (mysql_scripts_dir or general_scripts_dir) | search ("/usr") when: (mysql_scripts_dir or general_scripts_dir) | search ("/usr")
- name: Optimize script for MySQL - name: Optimize script for MySQL
@ -133,7 +135,8 @@
# my-add.sh # my-add.sh
- include: remount_usr_rw.yml - include_role:
name: remount-usr
when: (mysql_scripts_dir or general_scripts_dir) | search ("/usr") when: (mysql_scripts_dir or general_scripts_dir) | search ("/usr")
- name: Install my-add.sh - name: Install my-add.sh

View File

@ -28,7 +28,8 @@
state: directory state: directory
notify: restart nagios-nrpe-server notify: restart nagios-nrpe-server
- include: remount_usr_rw.yml - include_role:
name: remount-usr
when: nagios_plugins_directory | search ("/usr") when: nagios_plugins_directory | search ("/usr")
tags: tags:
- nagios-plugins - nagios-plugins

View File

@ -1,19 +0,0 @@
---
- name: Get mount options for partitions
shell: "mount | grep 'on /usr type'"
args:
warn: no
register: mount
changed_when: False
failed_when: False
when: not ansible_check_mode
- name: Remount /usr if it is a partition and it is not mounted in rw
command: "mount -o remount,rw /usr"
when:
- not ansible_check_mode
- mount.rc == 0
- not mount.stdout_lines.0 | search("rw")
check_mode: yes
args:
warn: no

View File

@ -66,25 +66,8 @@
tags: tags:
- opendkim - opendkim
- name: check if /usr is a partition - include_role:
shell: "mount | grep 'on /usr type'" name: remount-usr
args:
warn: no
changed_when: False
failed_when: False
register: usr_partition
check_mode: no
tags:
- opendkim
- name: mount /usr in rw
command: mount -o remount,rw /usr
args:
warn: no
changed_when: False
when: usr_partition.rc == 0
tags:
- opendkim
- name: deploy opendkim-add.sh script - name: deploy opendkim-add.sh script
copy: copy:

View File

@ -87,19 +87,8 @@
tags: tags:
- postfix - postfix
- name: update ansible_mounts facts - include_role:
setup: name: remount-usr
filter: ansible_mounts
tags:
- postfix
- name: mount /usr in rw
command: mount -o remount,rw /usr
args:
warn: no
changed_when: false
when: item.mount == '/usr' and item.options | match(".*ro.*")
with_items: "{{ ansible_mounts }}"
tags: tags:
- postfix - postfix

View File

@ -6,23 +6,10 @@
tags: tags:
- redis - redis
- name: Check if /usr is a partition - include_role:
shell: "mount | grep 'on /usr type'" name: remount-usr
args: tags:
warn: no - redis
changed_when: False
failed_when: False
check_mode: no
register: usr_partition
tags: redis
- name: Mount /usr in rw
command: mount -o remount,rw /usr
args:
warn: no
changed_when: False
when: usr_partition.rc == 0
tags: redis
- name: Create plugin directory - name: Create plugin directory
file: file:

View File

@ -0,0 +1,6 @@
---
- name: remount usr
command: mount -o remount /usr
failed_when: false
args:
warn: no

View File

@ -0,0 +1,16 @@
---
- name: check if /usr is a read-only partition
command: grep -E " /usr.*ro" /proc/mounts
args:
warn: no
changed_when: False
failed_when: False
check_mode: no
register: usr_partition
- name: mount /usr in rw
command: mount -o remount,rw /usr
args:
warn: no
when: usr_partition.rc == 0
notify: remount usr

View File

@ -27,19 +27,8 @@
tags: tags:
- spamassassin - spamassassin
- name: update ansible_mounts facts - include_role:
setup: name: remount-usr
filter: ansible_mounts
tags:
- spamassassin
- name: mount /usr in rw
command: mount -o remount,rw /usr
args:
warn: no
changed_when: false
when: item.mount == '/usr' and item.options | match(".*ro.*")
with_items: "{{ ansible_mounts }}"
tags: tags:
- spamassassin - spamassassin

View File

@ -4,21 +4,8 @@
name: monitoring-plugins name: monitoring-plugins
state: present state: present
- name: Check if /usr is a partition - include_role:
shell: "mount | grep 'on /usr type'" name: remount-usr
args:
warn: no
changed_when: False
failed_when: False
check_mode: no
register: usr_partition
- name: Mount /usr in rw
command: mount -o remount,rw /usr
args:
warn: no
changed_when: False
when: usr_partition.rc == 0
- name: Create Nagios plugins dir - name: Create Nagios plugins dir
file: file:

View File

@ -4,7 +4,9 @@
name: libxml-parser-perl name: libxml-parser-perl
tags: varnish tags: varnish
- include: remount_usr_rw.yml - include_role:
name: remount-usr
tags: varnish
- name: Create plugin directory - name: Create plugin directory
file: file:

View File

@ -1,19 +0,0 @@
---
- name: Get mount options for partitions
shell: "mount | grep 'on /usr type'"
args:
warn: no
register: mount
changed_when: False
failed_when: False
when: not ansible_check_mode
- name: Remount /usr if it is a partition and it is not mounted in rw
command: "mount -o remount,rw /usr"
when:
- not ansible_check_mode
- mount.rc == 0
- not mount.stdout_lines.0 | search("rw")
check_mode: yes
args:
warn: no

View File

@ -1,15 +0,0 @@
---
- name: Get mount options for partitions
shell: "mount | grep 'on /usr type'"
args:
warn: no
register: mount
changed_when: False
failed_when: False
when: not ansible_check_mode
- name: Remount /usr if it is a partition and it is not mounted in rw
command: "mount -o remount,rw /usr"
when: mount.rc == 0 and not mount.stdout_lines.0 | search("rw")
args:
warn: no

View File

@ -86,7 +86,8 @@
group: "adm" group: "adm"
mode: "0640" mode: "0640"
- include: remount_usr_rw.yml - include_role:
name: remount-usr
when: evoadminmail_scripts_dir | search ("/usr") when: evoadminmail_scripts_dir | search ("/usr")
- name: "Create {{ evoadminmail_scripts_dir }}" - name: "Create {{ evoadminmail_scripts_dir }}"

View File

@ -1,19 +0,0 @@
---
- name: Get mount options for partitions
shell: "mount | grep 'on /usr type'"
args:
warn: no
register: mount
changed_when: False
failed_when: False
when: not ansible_check_mode
- name: Remount /usr if it is a partition and it is not mounted in rw
command: "mount -o remount,rw /usr"
when:
- not ansible_check_mode
- mount.rc == 0
- not mount.stdout_lines.0 | search("rw")
check_mode: yes
args:
warn: no

View File

@ -52,7 +52,8 @@
group: "{{ evoadmin_username }}" group: "{{ evoadmin_username }}"
recurse: yes recurse: yes
- include: remount_usr_rw.yml - include_role:
name: remount-usr
when: evoadmin_scripts_dir | search ("/usr") when: evoadmin_scripts_dir | search ("/usr")
- name: "Create {{ evoadmin_scripts_dir }}" - name: "Create {{ evoadmin_scripts_dir }}"