---
- hosts: all
  become: yes
  gather_facts: no

  vars:
    application: cikit
    # Allow to pass "--restart=nginx,jenkins,apache" to this script and restart necessary services.
    restart: ""

  pre_tasks:
    - name: Ensure Python is installed on remote host
      raw: "[ $(which python) ] || (apt update -y && apt install python-minimal -y)"

      # "gather_facts" after performing required tasks.
    - name: Gather facts
      setup: ~

    - name: Determine domain
      set_fact:
        domain: "{{ domain | default(inventory_hostname) }}"

    - include_vars: "{{ item }}"
      with_fileglob: vars/*
      tags: ["always"]

    - name: Check Ansible compatibility
      fail:
        msg: "You need Ansible 2.x on your host machine!"
      when: "ansible_version.major < 2"

    - name: Configure hostname
      hostname:
        name: "{{ domain }}"

  roles:
    - role: apt
      tags: ["apt"]

    - role: virtualbox
      tags: ["vb"]

    - role: ssl
      tags: ["ssl"]

    - role: php-fpm
      tags: ["php-fpm"]

    - role: nginx
      tags: ["nginx"]

    - role: phpvirtualbox
      tags: ["phpvb"]

    - role: virtualmachine
      tags: ["vm"]

  tasks:
    - name: Restart service
      service:
        name: "{{ item }}"
        state: restarted
      with_items: "{{ restart.split(',') }}"
      when: restart | length > 0
      tags: ["always"]

---
- hosts: all
  become: yes
  gather_facts: no

  vars:
    application: cikit
    # Allow to pass "--restart=nginx,jenkins,apache" to this script and restart necessary services.
    restart: ""

  pre_tasks:
    - name: Ensure Python is installed on remote host
      raw: "[ $(which python) ] || (apt update -y && apt install python-minimal -y)"

      # "gather_facts" after performing required tasks.
      # See https://gist.github.com/gwillem/4ba393dceb55e5ae276a87300f6b8e6f#gistcomment-1869582
    - name: Gather facts
      setup: ~

    - name: Determine domain
      set_fact:
        domain: "{{ domain | default(inventory_hostname) }}"

    - include_vars: "{{ item }}"
      with_fileglob: vars/*
      tags: ["always"]

    - name: Check Ansible compatibility
      fail:
        msg: "You need Ansible 2.x on your host machine!"
      when: "ansible_version.major < 2"

    - name: Configure hostname
      hostname:
        name: "{{ domain }}"

  roles:
    - role: apt
      tags: ["apt"]

    - role: virtualbox
      tags: ["vb"]

    - role: ssl
      tags: ["ssl"]

    - role: php-fpm
      tags: ["php-fpm"]

    - role: nginx
      tags: ["nginx"]

    - role: phpvirtualbox
      tags: ["phpvb"]

    - role: virtualmachine
      tags: ["vm"]

  tasks:
    - name: Restart service
      service:
        name: "{{ item }}"
        state: restarted
      with_items: "{{ restart.split(',') }}"
      when: restart | length > 0
      tags: ["always"]

Add helpful comments to code
[CIKit][Matrix] Add helpful comments to code
