- name: Create httpd conf include directory ansible.builtin.file: path: "{{ httpd_conf_d }}" state: directory owner: root group: wheel mode: "0755" - name: Deploy httpd.conf ansible.builtin.template: src: httpd.conf.j2 dest: /etc/httpd.conf owner: root group: wheel mode: "0600" notify: restart httpd - name: Ensure all registered httpd fragment files exist # If they don't exist, httpd validate will fail. So we want to create them, # even if empty for now. ansible.builtin.copy: content: "" dest: "{{ httpd_conf_d }}/{{ item }}" force: false # If it already exists, don't overwrite it. owner: root group: wheel mode: "0644" loop: "{{ httpd_fragments }}" - name: Validate httpd config ansible.builtin.command: httpd -n changed_when: false - name: Enable httpd and slowcgi ansible.builtin.command: "rcctl enable {{ item }}" args: creates: "/etc/rc.conf.d/{{ item }}" loop: - httpd - slowcgi changed_when: true - name: Check service status ansible.builtin.command: rcctl check {{ item }} register: httpd_check changed_when: false failed_when: false # rc 1 exit code means "not running" loop: - httpd - slowcgi - name: Start services that are not running ansible.builtin.command: rcctl start {{ item.item }} loop: "{{ httpd_check.results }}" when: item.rc != 0