---

#
# Ansible configuration for Media Cloud
# ---
#
# Variables:
# 
#   * "mediacloud_production" -- set when deploying to production
#

- name: Set up Media Cloud
  hosts: all
  any_errors_fatal: true
  gather_facts: no
  pre_tasks:
    - name: Ensure that Ansible itself is up-to-date
      assert:
        that: "ansible_version.full | version_compare('2.3.2.0', '>=')"
        msg: "Please upgrade your Ansible to a newer version."
    - name: Install Python 2.7 for Ansible on Ubuntu
      raw: if [ `uname` != 'Darwin' ]; then sudo apt-get -y install python-simplejson; fi
    - name: Reload ansible_facts
      setup:
    - name: Install Aptitude  # https://github.com/ansible/ansible/issues/16884
      raw: apt-get -y install python-minimal aptitude
      become: true
      become_user: root
      become_method: sudo
      when: ansible_distribution == 'Ubuntu'
  roles:
    - update-packages
    - common
    - system-packages
    - postgresql-server
    - kernel-parameters

---

#
# Ansible configuration for Media Cloud
# ---
#
# Variables:
# 
#   * "mediacloud_production" -- set when deploying to production
#

- name: Set up Media Cloud
  hosts: all
  any_errors_fatal: true
  gather_facts: no
  pre_tasks:
    - name: Ensure that Ansible itself is up-to-date
      assert:
        that: "ansible_version.full | version_compare('2.3.2.0', '>=')"
        msg: "Please upgrade your Ansible to a newer version."
    - name: Install Python 2.7 for Ansible on Ubuntu
      raw: if [ `uname` != 'Darwin' ]; then sudo apt-get -y install python-simplejson; fi
      register: install_python_2_7_result
      changed_when: "'python-simplejson is already the newest version' not in install_python_2_7_result.stdout"
    - name: Reload ansible_facts
      setup:
    - name: Install Aptitude  # https://github.com/ansible/ansible/issues/16884
      command: apt-get -y install python-minimal aptitude
      args:
        warn: off # Disable "Consider using apt module rather than running apt-get" warning
      become: true
      register: install_aptitude_result
      changed_when: "'aptitude is already the newest version' not in install_aptitude_result.stdout"
      when: ansible_distribution == 'Ubuntu'
  roles:
    - update-packages
    - common
    - system-packages
    - postgresql-server
    - kernel-parameters

Test whether pre-install commands change anything
Test whether pre-install commands change anything
