Fix ldap dir on ansible playbook for backup roles

when running backup on Debian, ansible throws an error
on ldap db backup task.
error: "slapcat: 'bad configuration directory!'"

that's because ldap configuration directory changed on
debian from openldap to ldap

the fix this is to indentify the os distribution that
is currently using and do a conditional on ansible, to
differentiate the task on debian from centos, to be able
to fetch information from the correct directory depending
on the os.

Test Plan:
PASS: Build an image on Debian
PASS: Build an image on CentOS
PASS: Create backup on Debian
PASS: Create backup on CentOS

Story: 2009303
Task: 45477

Signed-off-by: Ramon Gazoni Lacerda <Ramon.GazoniLacerda@windriver.com>
Co-Authored-By: Daniel Stevens <DanielStevens.TorresCardenas@windriver.com>
Co-Authored-By: Thiago Brito <thiago.brito@windriver.com>
Change-Id: I84ea3ebb3c0f31c03d678c02fee79fc298492313
This commit is contained in:
Ramon Gazoni Lacerda 2022-05-25 16:33:28 -03:00 committed by Thiago Brito
parent 4ec4a8379f
commit b0e787b197
4 changed files with 22 additions and 13 deletions

View File

@ -326,8 +326,13 @@
set_fact:
ldap_db_backup: "{{ ldap_dir.path }}/ldap.db"
- name: Backup ldap db
- name: Backup LDAP DB on CentOS
command: "slapcat -d 0 -F /etc/openldap/schema -l {{ ldap_db_backup }}"
when: os_release == "centos"
- name: Backup LDAP DB on Debian
command: "slapcat -d 0 -F /etc/ldap/schema -l {{ ldap_db_backup }}"
when: os_release == "debian"
- block:
- name: Create ceph temp dir

View File

@ -9,17 +9,6 @@
# the next step.
#
# Check for Host OS release
- name: Gather Host OS release
raw: "grep '^NAME=' /etc/os-release | sed s'/NAME=//'"
register: distro
changed_when: false
- name: Set OS Release to Debian
set_fact:
os_release: "debian"
when: "'Debian' in distro.stdout"
- name: Set package lookup command
set_fact:
pkg_lookup_cmd: "{{ 'rpm -q' if os_release == 'centos' else 'dpkg -l' }}"

View File

@ -7,7 +7,6 @@ standard_root_disk_size: 500
temp_ssl_ca_dir: "/tmp"
temp_ssl_ca_file: "ca-cert.pem"
temp_k8s_plugins_dir: "/tmp"
os_release: "centos"
# KUBERNETES PARAMETERS
# =====================

View File

@ -8,6 +8,22 @@
# This role is to perform tasks that are common to the playbooks.
#
# Check for Host OS release
- name: Gather Host OS release
raw: "grep '^NAME=' /etc/os-release | sed s'/NAME=//'"
register: distro
changed_when: false
- name: Set OS Release to Debian
set_fact:
os_release: "debian"
when: "'Debian' in distro.stdout"
- name: Set OS Release to Centos
set_fact:
os_release: "centos"
when: "'Debian' not in distro.stdout"
# Include user override files for a play
- stat:
path: "{{ item }}"