---
- name: Prepare keitaro dir
  file:
    path={{ keitaro.path }}
    state=directory
    owner={{ os_user }}
    group={{ os_user }}
    mode=0777

- name: Download installer
  tags: keitaro
  get_url:
    url=http://keitarotds.com/getfile/install
    dest={{ keitaro.path }}/install.php

- name: Install Keitaro TDS
  tags: keitaro
  shell: |
    cd {{ keitaro.path }} && \
    sudo -u {{os_user}} php install.php install \
        --ip={{ license_ip }}  \
        --key={{ license_key }} \
        --db-user={{ db_user }} \
        --db-name={{ db_name }} \
        --db-password='{{ db_password }}' \
        --admin-login={{ admin_login }} \
        --admin-password='{{ admin_password }}' \
        --draft-storage=redis \
        --cache-storage=redis
  register: command_result
  failed_when: "'Installation Finished' not in command_result.stdout"

- name: Add cron task
  tags: keitaro
  cron:
    user="{{os_user}}"
    name="keitaro"
    job="php {{ keitaro.path }}/cron.php"

---
- name: Prepare keitaro dir
  file:
    path={{ keitaro.path }}
    state=directory
    owner={{ os_user }}
    group={{ os_user }}
    mode=0777

- name: Download installer
  tags: keitaro
  get_url:
    url=http://keitarotds.com/getfile/install
    dest={{ keitaro.path }}/install.php

- name: Install Keitaro TDS
  tags: keitaro
  command: |
      /usr/bin/php install.php install --ip={{ license_ip }} \
                                       --key={{ license_key }} \
                                       --db-user={{ db_user }} \
                                       --db-name={{ db_name }} \
                                       --db-password='{{ db_password }}' \
                                       --admin-login={{ admin_login }} \
                                       --admin-password='{{ admin_password }}' \
                                       --draft-storage=redis \
                                       --cache-storage=redis
  args:
    chdir: "{{ keitaro.path }}"
  become_user: "{{ os_user }}"
  register: command_result
  failed_when: "'Installation Finished' not in command_result.stdout"

- name: Add cron task
  tags: keitaro
  cron:
    user="{{os_user}}"
    name="keitaro"
    job="php {{ keitaro.path }}/cron.php"

Use command module instead of shell
Use command module instead of shell
