diff --git a/handlers/main.yml b/handlers/main.yml index 1404c0c..c674128 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -10,3 +10,8 @@ service: name: nginx state: reloaded + +- name: "(Handler: All OSs) Start NGINX Unit" + service: + name: unit + state: started diff --git a/tasks/unit/install-unit.yml b/tasks/unit/install-unit.yml new file mode 100644 index 0000000..d27eb8f --- /dev/null +++ b/tasks/unit/install-unit.yml @@ -0,0 +1,101 @@ +--- +- import_tasks: setup-debian.yml + when: ansible_os_family == "Debian" + +- import_tasks: setup-redhat.yml + when: ansible_os_family == "RedHat" + +- name: "(Install: All OSs) Install NGINX Unit" + package: + name: unit + state: present + notify: "(Handler: All OSs) Start NGINX Unit" + +- name: "(Install: All OSs) Install NGINX Unit" + package: + name: "{{ item }}" + state: present + with_items: + - unit-php + - unit-python + - unit-go + - unit-perl + when: ansible_distribution == "CentOS" + notify: "(Handler: All OSs) Start NGINX Unit" + +- name: "(Install: All OSs) Install NGINX Unit" + package: + name: "{{ item }}" + state: present + with_items: + - unit-php + - unit-python + - unit-perl + when: ansible_distribution == "RedHat" and ansible_distribution_major_version|int == 6 + notify: "(Handler: All OSs) Start NGINX Unit" + +- name: "(Install: All OSs) Install NGINX Unit" + package: + name: "{{ item }}" + state: present + with_items: + - unit-php + - unit-python + - unit-go + - unit-perl + when: ansible_distribution == "RedHat" and ansible_distribution_major_version|int == 6 + notify: "(Handler: All OSs) Start NGINX Unit" + +- name: "(Install: All OSs) Install NGINX Unit" + package: + name: "{{ item }}" + state: present + with_items: + - unit-php + - unit-python27 + - unit-python34 + - unit-python35 + - unit-python36 + - unit-go + - unit-perl + when: ansible_distribution == "Amazon" + notify: "(Handler: All OSs) Start NGINX Unit" + +- name: "(Install: All OSs) Install NGINX Unit" + package: + name: "{{ item }}" + state: present + with_items: + - unit-php + - unit-python2.7 + - unit-python3.5 + - unit-go + - unit-perl + when: ansible_distribution == "Ubuntu" and ansible_distribution_major_version|int == 16 + notify: "(Handler: All OSs) Start NGINX Unit" + +- name: "(Install: All OSs) Install NGINX Unit" + package: + name: "{{ item }}" + state: present + with_items: + - unit-php + - unit-python2.7 + - unit-python3.4 + - unit-perl + when: ansible_distribution == "Debian" and ansible_distribution_major_version|int == 8 + notify: "(Handler: All OSs) Start NGINX Unit" + +- name: "(Install: All OSs) Install NGINX Unit" + package: + name: "{{ item }}" + state: present + with_items: + - unit-php + - unit-python2.7 + - unit-python3.5 + - unit-go1.7 + - unit-go1.8 + - unit-perl + when: ansible_distribution == "RedHat" and ansible_distribution_major_version|int == 9 + notify: "(Handler: All OSs) Start NGINX Unit" diff --git a/tasks/unit/setup-debian.yml b/tasks/unit/setup-debian.yml new file mode 100644 index 0000000..114fc45 --- /dev/null +++ b/tasks/unit/setup-debian.yml @@ -0,0 +1,11 @@ +--- +- name: "(Install: Debian/Ubuntu) Add NGINX Unit Repository" + apt_repository: + repo: "{{ item }}" + with_items: + - deb https://packages.nginx.org/unit/{{ ansible_distribution|lower }}/ {{ ansible_distribution_release }} unit + - deb-src https://packages.nginx.org/unit/{{ ansible_distribution|lower }}/ {{ ansible_distribution_release }} unit + +- name: "(Install: Debian/Ubuntu) Update APT Cache" + apt: + update_cache: yes diff --git a/tasks/unit/setup-redhat.yml b/tasks/unit/setup-redhat.yml new file mode 100644 index 0000000..05e6c6f --- /dev/null +++ b/tasks/unit/setup-redhat.yml @@ -0,0 +1,27 @@ +--- +- name: "(Install: RedHat) Add NGINX Unit Repository" + yum_repository: + name: nginx + baseurl: https://packages.nginx.org/unit/rhel/$releasever/$basearch/ + description: NGINX Repository + enabled: yes + gpgcheck: yes + when: ansible_distribution == "RedHat" + +- name: "(Install: CentOS) Add NGINX Unit Repository" + yum_repository: + name: nginx + baseurl: https://packages.nginx.org/unit/centos/$releasever/$basearch/ + description: NGINX Repository + enabled: yes + gpgcheck: yes + when: ansible_distribution == "CentOS" + +- name: "(Install: Amazon Linux) Add NGINX Unit Repository" + yum_repository: + name: nginx + baseurl: https://packages.nginx.org/unit/amzn/$releasever/$basearch/ + description: NGINX Repository + enabled: yes + gpgcheck: yes + when: ansible_distribution == "Amazon"