Nginx installation using Ansible Playbook

 ---
- hosts: test-server
  gather_facts: yes
  connection: ssh
  tasks:
  - name: install nginx
    yum:
        name: nginx
        state: latest
  - name: enable and start the nginx service
    service:
        name: nginx
        enabled: yes
        state: restarted

For removing the nginx service run the following one.

 ansible 'test-server' -s -m yum -a "name=nginx state=absent"  

Post navigation

Leave a Reply