From 6293be89a09256278d27a7af5e650154970f9786 Mon Sep 17 00:00:00 2001 From: Juan Badia Payno Date: Mon, 21 Sep 2020 16:51:50 +0200 Subject: [PATCH] BaR: Keep /etc/exports content Currently the backup and restore role when is installing the nfs server, the role uses a template to generate the /etc/exports file. This means that if there already an nfs server installed with its configuration the /etc/exports will be overwritten. This patch keeps the configuration of the /etc/exports and appends the "new" part. Closes-Bug: #1897503 Closes BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1878480 Change-Id: I0b943047be06153504fabe895711cce789621ac5 --- .../backup_and_restore/tasks/setup_nfs.yml | 19 +++++++++++-------- .../backup_and_restore/templates/exports.j2 | 8 -------- 2 files changed, 11 insertions(+), 16 deletions(-) delete mode 100644 tripleo_ansible/roles/backup_and_restore/templates/exports.j2 diff --git a/tripleo_ansible/roles/backup_and_restore/tasks/setup_nfs.yml b/tripleo_ansible/roles/backup_and_restore/tasks/setup_nfs.yml index ce68062c9..711999cd5 100644 --- a/tripleo_ansible/roles/backup_and_restore/tasks/setup_nfs.yml +++ b/tripleo_ansible/roles/backup_and_restore/tasks/setup_nfs.yml @@ -85,14 +85,17 @@ tags: - bar_setup_nfs_server -- name: Generate NFS exports table in the server - become: true - template: - src: exports.j2 - dest: /etc/exports - owner: root - group: root - mode: '0644' +- name: Get the lines + set_fact: + bar_exportfs_lines: "{% for net in tripleo_backup_and_restore_nfs_clients_nets %}\ + {{ tripleo_backup_and_restore_nfs_storage_folder }} {{ net }}(rw,sync,no_root_squash,no_subtree_check)\n{% endfor %}" + tags: + - bar_setup_nfs_server + +- name: NFS + blockinfile: + path: /etc/exports + block: "{{bar_exportfs_lines}}" backup: true tags: - bar_setup_nfs_server diff --git a/tripleo_ansible/roles/backup_and_restore/templates/exports.j2 b/tripleo_ansible/roles/backup_and_restore/templates/exports.j2 deleted file mode 100644 index 96572ad36..000000000 --- a/tripleo_ansible/roles/backup_and_restore/templates/exports.j2 +++ /dev/null @@ -1,8 +0,0 @@ -# This configuration file is generated automatically -# by the backup_and_restore role part of TripleO -# Ansible. No not edit this file, all changes -# will be lost. Refer to the following URL for -# more information and implementation details: -# https://opendev.org/openstack/tripleo-ansible - -{{ tripleo_backup_and_restore_nfs_storage_folder }} {% for net in tripleo_backup_and_restore_nfs_clients_nets %}{{ net }}(rw,sync,no_root_squash,no_subtree_check) {% endfor %}