# # Remount partitions /usr and /tmp respectively with rw and exec. # This must be done before trying to write on /usr or execute something in # /tmp. # # Usage in playbooks: # # - include: inc/tasks/remount-on.yml # vars: # partitions: # - "/tmp" # - "/usr" --- - name: Get mount options for partitions shell: "mount | grep 'on {{ item }} type'" register: mount changed_when: False failed_when: False when: not ansible_check_mode with_items: "{{ partitions }}" - name: Remount /usr if it is a partition and it is not mounted in rw command: "mount -o remount,rw {{ item.0 }}" when: item.0 == "/usr" and item.1.rc == 0 and not item.1.stdout_lines.0|search("rw") with_together: - "{{ partitions }}" - "{{ mount.results }}" - name: Remount /tmp if it is a partition and it is mounted in noexec command: "mount -o remount,exec {{ item.0 }}" when: item.0 == "/tmp" and item.1.rc == 0 and item.1.stdout_lines.0|search("noexec") with_together: - "{{ partitions }}" - "{{ mount.results }}"