47 lines
1.2 KiB
YAML
Raw Normal View History

2022-03-17 09:00:06 +01:00
---
2023-10-13 15:00:23 +02:00
- name: Deploy env file
template: src=ldap2pg.env.j2 dest=/etc/sysconfig/ldap2pg owner=root group=postgres mode=640
tags: pg
2022-03-17 09:00:06 +01:00
- name: Deploy ldap2pg configuration
block:
- name: Render config template
template:
src: ldap2pg.yml.j2
dest: "/etc/ldap2pg.yml"
owner: "{{ ldap2pg_user }}"
group: "{{ ldap2pg_user }}"
mode: 0600
backup: True
register: ldap2pg_rendered_conf
notify:
- restart ldap2pg.timer
- name: Validate new configuration
2023-10-13 15:00:23 +02:00
command: /usr/local/bin/ldap2pg --config /etc/ldap2pg.yml
2022-03-17 09:00:06 +01:00
changed_when: False
become_user: "{{ ldap2pg_user }}"
register: ldap2pg_conf_validation
2023-10-13 15:00:23 +02:00
environment: "{{ ldap2pg_env }}"
2022-03-17 09:00:06 +01:00
rescue:
- name: Rollback previous configuration
copy:
src: "{{ ldap2pg_rendered_conf.backup_file }}"
dest: /etc/ldap2pg.yml
remote_src: True
owner: "{{ ldap2pg_user }}"
group: "{{ ldap2pg_user }}"
mode: 0600
when: ldap2pg_rendered_conf.backup_file is defined
tags: pg
- name: Fails if new configuration isn't validated
fail:
2023-10-13 15:00:23 +02:00
msg: "Failed to validate /etc/ldap2pg.yml: {{ ldap2pg_conf_validation.stdout }}"
2022-03-17 09:00:06 +01:00
when: ldap2pg_conf_validation.rc != 0
tags: pg
2023-10-13 15:00:23 +02:00