Playbook to install and start nginx on ubuntu

0 votes
I'm very new to ansible and I would like to know how to write a playbook to install and start nginx on ubuntu. Thank you
Mar 15, 2019 in Ansible by Kabeer
2,595 views

1 answer to this question.

0 votes

Write your playbook like this:

---
- hosts: droplets
  tasks:
    - name: Installs nginx web server
      apt: pkg=nginx state=installed update_cache=true
      notify:
        - start nginx

  handlers:
    - name: start nginx
      service: name=nginx state=started
answered Mar 15, 2019 by Deep

This is how you install NGINX on ubuntu, above code is outdated.

---

- hosts: AppServer

  become: yes

  tasks:

  - name: Installs nginx web server

    apt:

      name: nginx

      state: present

      update_cache: true

    notify:

    - start nginx

  handlers:

  - name: start nginx

    service:

      name: nginx

      state: present

Related Questions In Ansible

+1 vote
1 answer

Ansible-playbook to install and configure Nginx+Nodejs+Npm+PM2

Try thhis out: --- - hosts: hosts tasks: ...READ MORE

answered Sep 3, 2019 in Ansible by Kalgi
• 51,890 points
1,498 views
0 votes
1 answer

Requirements to install MySQL and MariaDB on ubuntu - Ansible

You don't really need anything specific. Just ...READ MORE

answered Oct 24, 2019 in Ansible by Bob
111 views
0 votes
1 answer
0 votes
1 answer
0 votes
2 answers
0 votes
2 answers

Ansible error while ansible -m ping all

It looks like ansible may be installed ...READ MORE

answered Mar 18, 2019 in Ansible by Vince
763 views
0 votes
1 answer

Unable to install Ansible on centOS

Seems like you're stuck at creating ansible ...READ MORE

answered Dec 19, 2018 in Ansible by Alan
85 views
0 votes
1 answer

Install mean stack on ubuntu using ansible

You can have three roles  under /etc/ansible/roles -prerequisites -mongodb -nodejs under /etc/ansible ...READ MORE

answered Mar 15, 2019 in Ansible by Janice
210 views