Back to articles
Ansible Has a Free API: Automate Everything Without Agents
How-ToDevOps

Ansible Has a Free API: Automate Everything Without Agents

via Dev.toAlex Spinov

Why Ansible Ansible automates server configuration, application deployment, and orchestration — all agentless, over SSH. Write playbooks in YAML, run them against any server. Install pip install ansible Inventory # inventory.ini [web] web1.example.com web2.example.com [db] db1.example.com [all:vars] ansible_user = deploy ansible_python_interpreter = /usr/bin/python3 First Playbook # deploy.yaml - hosts : web become : true tasks : - name : Install Nginx apt : name : nginx state : present update_cache : true - name : Copy config template : src : nginx.conf.j2 dest : /etc/nginx/nginx.conf notify : Restart Nginx - name : Ensure Nginx is running service : name : nginx state : started enabled : true handlers : - name : Restart Nginx service : name : nginx state : restarted ansible-playbook -i inventory.ini deploy.yaml Roles (Reusable Components) ansible-galaxy init roles/webserver # roles/webserver/tasks/main.yaml - name : Install packages apt : name : " {{ item }}" state : present loop : -

Continue reading on Dev.to

Opens in a new tab

Read Full Article
2 views

Related Articles