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
11,923 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

0 votes
1 answer

How to write ansible playbook to setup ubuntu workstation and install any updates on it

Hi@Shashi, Ansible has one module named ec2. This is ...READ MORE

answered Nov 19, 2020 in Ansible by MD
• 95,460 points
1,257 views
+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
• 52,350 points
9,645 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
668 views
+1 vote
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
3,315 views
0 votes
1 answer

Unable to install Ansible on centOS

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

answered Dec 20, 2018 in Ansible by Alan
691 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
1,207 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP