forked from infra/ansible
[postfix] Move lmdb handler to separate file
After merging I found out that the handler can't handle blocks. The workaround is to include tasks from separate file. Signed-off-by: Michal Konecny <mkonecny@redhat.com>
This commit is contained in:
parent
48f3055721
commit
e6f7c234ab
2 changed files with 29 additions and 27 deletions
|
|
@ -52,30 +52,5 @@
|
|||
when: ansible_virtualization_role == 'host'
|
||||
|
||||
- name: Create lmdb files
|
||||
block:
|
||||
- name: Read the config file
|
||||
ansible.builtin.slurp:
|
||||
src: /etc/postfix/main.cf
|
||||
register: maincf_content
|
||||
|
||||
- name: Find all the lmdb files
|
||||
ansible.builtin.set_fact:
|
||||
lmdb_files: "{{ (maincf.content | b64decode) | regex_findall('lmdb:(.*)') }}"
|
||||
|
||||
- name: Convert /etc/alises to lmdb
|
||||
ansible.builtin.command: "postalias lmdb:{{ item }}"
|
||||
args:
|
||||
creates: "{{ item }}"
|
||||
when: "item == /etc/aliases"
|
||||
loop: "{{ lmdb_files }}"
|
||||
register: result
|
||||
failed_when: result.rc != 0
|
||||
|
||||
- name: Convert to lmdb
|
||||
ansible.builtin.command: "postmap lmdb:{{ item }}"
|
||||
args:
|
||||
creates: "{{ item }}"
|
||||
when: "item != /etc/aliases"
|
||||
loop: "{{ lmdb_files }}"
|
||||
register: result
|
||||
failed_when: result.rc != 0
|
||||
ansible.builtin.include_tasks: lmdb.yml
|
||||
listen: "Create lmdb files"
|
||||
|
|
|
|||
27
roles/base/tasks/lmdb.yml
Normal file
27
roles/base/tasks/lmdb.yml
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
---
|
||||
- name: Read the config file
|
||||
ansible.builtin.slurp:
|
||||
src: /etc/postfix/main.cf
|
||||
register: maincf_content
|
||||
|
||||
- name: Find all the lmdb files
|
||||
ansible.builtin.set_fact:
|
||||
lmdb_files: "{{ (maincf.content | b64decode) | regex_findall('lmdb:(.*)') }}"
|
||||
|
||||
- name: Convert /etc/alises to lmdb
|
||||
ansible.builtin.command: "postalias lmdb:{{ item }}"
|
||||
args:
|
||||
creates: "{{ item }}"
|
||||
when: "item == /etc/aliases"
|
||||
loop: "{{ lmdb_files }}"
|
||||
register: result
|
||||
failed_when: result.rc != 0
|
||||
|
||||
- name: Convert to lmdb
|
||||
ansible.builtin.command: "postmap lmdb:{{ item }}"
|
||||
args:
|
||||
creates: "{{ item }}"
|
||||
when: "item != /etc/aliases"
|
||||
loop: "{{ lmdb_files }}"
|
||||
register: result
|
||||
failed_when: result.rc != 0
|
||||
Loading…
Add table
Add a link
Reference in a new issue