--- - hosts: all tasks: - name: Define variables for CentOS set_fact: mysqld_safe_path: "/usr/bin/mysqld_safe" when: ansible_distribution == "CentOS" - name: Define variables for FreeBSD set_fact: mysqld_safe_path: "/usr/local/bin/mysqld_safe" when: ansible_distribution == "FreeBSD" - name: check that "{{ mysqld_safe_path }}" contains a line command: grep -q " log_notice \"Adding" "{{ mysqld_safe_path }}" register: checkline failed_when: checkline.rc != 0 changed_when: False - name: add lines blockinfile: dest: "{{ mysqld_safe_path }}" insertafter: ' log_notice "Adding' backup: yes marker: "# {mark} CVE-2016-6662 patch" block: |2 # Check if the library is in the reduced number of standard system directories case "$lib_to_add" in /usr/lib64/* | /usr/lib/* | /usr/local/lib/* | ${MY_BASEDIR_VERSION}/lib/*) ;; *) log_error "ld_preload libraries can only be loaded from system directories (/usr/lib64, /usr/lib, /usr/local/lib, ${MY_BASEDIR_VERSION}/lib)" exit 1 ;; esac - name: add an empty line before the block to make it look better lineinfile: dest: "{{ mysqld_safe_path }}" insertafter: ' log_notice "Adding' line: ' '