Sobes.tech
Junior — Middle

Pode dar um exemplo de um playbook Ansible que criou ou implementou na sua prática?

sobes.tech IA

Resposta da IA

yaml

  • name: Instalação e execução do nginx hosts: webservers become: yes tasks:
    • name: Instalar nginx apt: name: nginx state: present update_cache: yes

    • name: Iniciar e habilitar nginx systemd: name: nginx state: started enabled: yes

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

Este playbook instala o servidor web nginx no grupo de hosts webservers, inicia-o e habilita-o para iniciar automaticamente, e também copia a página personalizada index.html.