---
- hosts: localhost
  gather_facts: no
  tasks:
    - name: check for security
      when: security_enabled is not defined or not security_enabled
      fail:
        msg: |
          Security is not enabled. Please run `security-setup` in the root
          directory and re-run this playbook with the `--extra-vars`/`-e` option
          pointing to your `security.yml` (e.g., `-e @security.yml`)

    # Change concurrently with the required ansible version in requirements.txt
    - name: check for compatible Ansible version
      when: ansible_version["string"] | version_compare("1.9.1", "<") or ansible_version["string"] | version_compare("2", ">=")
      fail:
        msg: |
          Your version of Ansible doesn't match the required version. Please
          install ansible-playbook with `pip install -r requirements.txt`.

- hosts: all
  gather_facts: yes
  tasks:
    - name: check for compatible centos version
      when: ansible_distribution_version | version_compare("7.2", "<")
      fail:
        msg: |
          Your hosts don't appear to be running a compatible version of Centos.
          Please run the playbook playbooks/upgrade-packages.yml before
          continuing.

    - name: check for compatible kernel version
      when: ansible_kernel | version_compare("3.10.0-327", "<")
      fail:
        msg: |
          Your hosts don't appear to be running a compatible version of the
          Linux kernel. Please run the playbook playbooks/upgrade-packages.yml
          before continuing.

---
- hosts: localhost
  gather_facts: no
  tasks:
    - name: check for security
      when: security_enabled is not defined or not security_enabled
      fail:
        msg: |
          Security is not enabled. Please run `security-setup` in the root
          directory and re-run this playbook with the `--extra-vars`/`-e` option
          pointing to your `security.yml` (e.g., `-e @security.yml`)

    # Change concurrently with the required ansible version in requirements.txt
    - name: check for compatible Ansible version
      when: >
        ansible_version["string"] | version_compare("1.9.1", "<")
        or ansible_version["string"] | version_compare("2", ">=")
      fail:
        msg: |
          Your version of Ansible doesn't match the required version. Please
          install ansible-playbook with `pip install -r requirements.txt`.

- hosts: all
  gather_facts: yes
  tasks:
    - name: check for compatible centos version
      when: ansible_distribution_version | version_compare("7.2", "<")
      fail:
        msg: |
          Your hosts don't appear to be running a compatible version of Centos.
          Please run the playbook playbooks/upgrade-packages.yml before
          continuing.

    - name: check for compatible kernel version
      when: >
        ansible_kernel | version_compare("3.10.0-327", "<")
        and provider != "digitalocean"
        and provider != "packer"
      fail:
        msg: |
          Your hosts don't appear to be running a compatible version of the
          Linux kernel. Please run the playbook playbooks/upgrade-packages.yml
          before continuing.

Remove kernel version requirement on digitalocean
Remove kernel version requirement on digitalocean

Tested on DO, deploys sucessfully
