--- - hosts: localhost tasks: - name: Add nginx apt repository key for Debian < 8 apt_key: url: http://nginx.org/keys/nginx_signing.key state: present become: yes become_user: root when: ansible_distribution == 'Debian' and ansible_distribution_version | version_compare('8', 'lt') - name: Add nginx apt repository for Debian < 8 apt_repository: repo: 'deb [arch=amd64,i386] http://nginx.org/packages/debian/ {{ ansible_distribution_release }} nginx' state: present become: yes become_user: root when: ansible_distribution == 'Debian' and ansible_distribution_version | version_compare('8', 'lt') ##################################### # Ubuntu Production Environment Setup - name: Install production pre-requisites become: yes become_user: root apt: pkg={{ item }} state=present with_items: - nginx - screen - vim - htop - git - postfix - supervisor when: ansible_distribution == 'Ubuntu' or ansible_distribution == 'Debian' ##################################### # CentOS Production Environment Setup - name: Install production pre-requisites become: yes become_user: root yum: pkg={{ item }} state=present with_items: - nginx - screen - vim - htop - git - postfix - MySQL-python when: ansible_distribution == 'CentOS' - name: Install supervisor using yum for Centos 7 yum: pkg=supervisor state=present become: yes become_user: root when: ansible_distribution == 'CentOS' and ansible_lsb.major_release == '7' #################################################### # Replace default nginx config with nginx template - name: Rename default nginx.conf to nginx.conf.old command: mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf.old become: yes become_user: root - name: Copy the nginx_config template template: src: ../templates/default_nginx.j2 dest: /etc/nginx/nginx.conf become: yes become_user: root - name: Reload the nginx service service: name: nginx state: restarted become: yes become_user: root #################################################### # Enable nginx, mysql, redis and supevisord services - name: Enable nginx, mysql, and redis service: name: '{{ item }}' enabled: yes with_items: - nginx - mysql become: yes become_user: root - name: Enable redis.service on centos service: name: redis enabled: yes become: yes become_user: root when: ansible_distribution == 'CentOS' - name: Enable redis-server.service on ubuntu service: name: redis-server enabled: yes become: yes become_user: root when: ansible_distribution == 'Ubuntu' or ansible_distribution == 'Debian' - name: Check whether default supervisor.conf exists service: name: supervisord state: started enabled: yes become: yes become_user: root when: ansible_distribution == 'CentOS' - name: Check whether default supervisor.conf exists service: name: supervisor state: started enabled: yes become: yes become_user: root when: ansible_distribution == 'Ubuntu' or ansible_distribution == 'Debian'