Sobes.tech
Junior — Middle

Can you provide an example of an Ansible playbook that you have created or implemented in your practice?

sobes.tech AI

Answer from AI

yaml

  • name: Install and start nginx hosts: webservers become: yes tasks:
    • name: Install nginx apt: name: nginx state: present update_cache: yes

    • name: Start and enable nginx systemd: name: nginx state: started enabled: yes

    • name: Copy index.html copy: src: files/index.html dest: /var/www/html/index.html owner: www-data group: www-data mode: '0644'

This playbook installs the nginx web server on the webservers group of hosts, starts and enables it to run on boot, and also copies a custom index.html page.