From a08304d8c030f0787079fce2d0a7e611ea00b95f Mon Sep 17 00:00:00 2001 From: David Kilias Date: Tue, 14 Nov 2023 07:34:21 +0100 Subject: [PATCH] fix: change rendering of domains.txt to template --- tasks/domains.yml | 11 +++++------ templates/domains.txt.j2 | 2 ++ 2 files changed, 7 insertions(+), 6 deletions(-) create mode 100644 templates/domains.txt.j2 diff --git a/tasks/domains.yml b/tasks/domains.yml index 6bbb781..65a4454 100644 --- a/tasks/domains.yml +++ b/tasks/domains.yml @@ -1,12 +1,12 @@ --- - name: Ensure domain directories are present. - file: + ansible.builtin.file: name: "{{ dehydrated_certs_dir }}/{{ item.name }}" state: directory with_items: "{{ dehydrated_domains }}" - name: Render hook script templates. - template: + ansible.builtin.template: src: hook.sh.j2 dest: "{{ dehydrated_certs_dir }}/{{ item.name }}/hook.sh" mode: '755' @@ -21,8 +21,7 @@ with_items: "{{ dehydrated_domains }}" - name: Ensure Domains are in domains.txt - lineinfile: - path: "{{ dehydrated_config_dir }}/domains.txt" - line: "{{ item.name }}{% if 'alternate_names' in item %}{% for an in item.alternate_names %} {{ an|default(omit) }}{% endfor %}{% endif %}" - with_items: "{{ dehydrated_domains }}" + ansible.builtin.template: + src: domains.txt.j2 + dest: "{{ dehydrated_config_dir }}/domains.txt" notify: dehydrated run diff --git a/templates/domains.txt.j2 b/templates/domains.txt.j2 new file mode 100644 index 0000000..3a2dbd9 --- /dev/null +++ b/templates/domains.txt.j2 @@ -0,0 +1,2 @@ +{% for domain in dehydrated_domains %}{{ domain.name }}{% if 'alternate_names' in domain %}{% for an in domain.alternate_names %} {{ an|default(omit) }}{% endfor %}{% endif %} +{% endfor %} \ No newline at end of file