|
| 1 | +--- |
| 2 | +- name: Template the roadrunner config ({{ roadrunner_config.key }}) |
| 3 | + register: roadrunner_template_config_result |
| 4 | + loop_control: |
| 5 | + label: "{{ roadrunner_config.key }}" |
| 6 | + ansible.builtin.template: |
| 7 | + src: roadrunner/rr.yaml.j2 |
| 8 | + dest: "{{ roadrunner.prefix.config }}/{{ roadrunner_config.key }}/rr.yaml" |
| 9 | + owner: root |
| 10 | + mode: "0644" |
| 11 | + |
| 12 | +- name: Check if the PHP script exists ({{ roadrunner_config.key }}) |
| 13 | + register: roadrunner_php_script_exists |
| 14 | + ansible.builtin.stat: |
| 15 | + path: "{{ roadrunner.prefix.current_release }}/{{ roadrunner.config[roadrunner_config.key].script_name | default(roadrunner.defaults.script_name) }}" |
| 16 | + |
| 17 | +- name: Template supervisord configuration for Roadrunner |
| 18 | + register: roadrunner_template_service_config_result |
| 19 | + ansible.builtin.template: |
| 20 | + src: supervisord.d/roadrunner.conf |
| 21 | + dest: "{{ supervisord.prefix.config }}/roadrunner-{{ roadrunner_config.key }}.conf" |
| 22 | + owner: root |
| 23 | + mode: "0644" |
| 24 | + |
| 25 | +- name: Enable and start the roadrunner-{{ roadrunner_config.key }} service if PHP script exists |
| 26 | + register: roadrunner_service_supervisord_started |
| 27 | + community.general.supervisorctl: |
| 28 | + name: "roadrunner-{{ roadrunner_config.key }}" |
| 29 | + state: "{{ 'present' if roadrunner_php_script_exists.stat.exists else 'absent' }}" |
| 30 | + stop_before_removing: yes |
| 31 | + |
| 32 | +- name: Restart the roadrunner-{{ roadrunner_config.key }} service |
| 33 | + when: roadrunner_php_script_exists.stat.exists and not roadrunner_service_supervisord_started.changed and (roadrunner_template_service_config_result.changed or roadrunner_template_config_result.changed or (roadrunner_version is defined and roadrunner_version.stdout != roadrunner.version)) |
| 34 | + community.general.supervisorctl: |
| 35 | + name: "roadrunner-{{ roadrunner_config.key }}" |
| 36 | + state: restarted |
0 commit comments