Created
December 18, 2017 04:57
-
-
Save ragingprodigy/629f59555bd26aa281a0d669ad25b487 to your computer and use it in GitHub Desktop.
Ansible Playbook to Install Nginx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- hosts: all | |
sudo: yes | |
tasks: | |
- name: check registered the repository of nginx-release | |
shell: rpm -qa | grep nginx-release | |
register: result | |
ignore_errors: True | |
always_run: yes | |
changed_when: no | |
- name: add repository nginx-release (CentOS6/CentOS7) | |
yum: name="http://nginx.org/packages/centos/{{ansible_distribution_major_version}}/noarch/RPMS/nginx-release-centos-{{ansible_distribution_major_version}}-0.el{{ansible_distribution_major_version}}.ngx.noarch.rpm" | |
when: result|failed | |
- name: disable the repository (pls set --enablerepo=nginx if you use it) | |
replace: dest=/etc/yum.repos.d/nginx.repo regexp="enabled *= *1" replace="enabled=0" | |
ignore_errors: True | |
- name: install nginx | |
yum: name=nginx state=present enablerepo=nginx | |
- name: Start Nginx | |
service: name=nginx enabled=yes state=started |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment