- name: Download and unpack RoadRunner
  shell: >
    curl -sSL https://github.com/spiral/roadrunner/releases/download/v{{ rr_version }}/roadrunner-{{ rr_version }}-linux-amd64.tar.gz | \
     tar -xz --no-same-owner --no-same-permissions --strip 1 roadrunner-{{ rr_version }}-linux-amd64/rr
  args:
    chdir: /usr/local/bin

- name: Install roadrunner SystemD service
  systemd:

- name: Generate roadrunner config
  template:
    src: roadrunner.yml.j2
    dest: "{{ configs_root }}/roadrunner.yml"

- name: Generate roadrunner systemd unit file into place.
  template:
    src: roadrunner.service.j2
    dest: /etc/systemd/system/roadrunner.service

- name: Enable and start roadrunner service
  systemd:
    daemon-reload: true
    name: roadrunner
    state: started
    enabled: yes


- name: Download and unpack RoadRunner
  shell: >
    curl -sSL https://github.com/spiral/roadrunner/releases/download/v{{ rr_version }}/roadrunner-{{ rr_version }}-linux-amd64.tar.gz | \
     tar -xz --no-same-owner --no-same-permissions --strip 1 roadrunner-{{ rr_version }}-linux-amd64/rr
  args:
    chdir: /usr/local/bin

- name: Install roadrunner SystemD service
  systemd:

- name: Generate roadrunner config
  template:
    src: roadrunner.yml.j2
    dest: "{{ configs_root }}/roadrunner.yml"

- name: Generate roadrunner systemd unit file into place.
  template:
    src: roadrunner.service.j2
    dest: /etc/systemd/system/roadrunner.service

- name: Enable and start roadrunner service if engine is roadrunner
  systemd:
    daemon-reload: true
    name: roadrunner
    state: started
    enabled: yes
  when: "php_engine == 'roadrunner'"

- name: Disable and stop roadrunner service if engine is not roadrunner
  systemd:
    daemon-reload: true
    name: roadrunner
    state: stopped
    enabled: no
  when: "php_engine != 'roadrunner'"

Disable roadrunner if php_engine is php-fpm
Disable roadrunner if php_engine is php-fpm
