« Ansible - Infrastructure-as-a-Code » : différence entre les versions

De Marijan Stajic | Wiki
Aller à la navigation Aller à la recherche
mAucun résumé des modifications
mAucun résumé des modifications
Ligne 7 : Ligne 7 :
Developing '''scripts''' for these tasks '''requires time''', '''coding skills''', and '''ongoing maintenance'''. With Ansible, automation becomes simple and efficient
Developing '''scripts''' for these tasks '''requires time''', '''coding skills''', and '''ongoing maintenance'''. With Ansible, automation becomes simple and efficient


== Configuration Files ==
== Configuration Files and Playbook ==
 
Ansible provides a default '''configuration file''', usually located at '''/etc/ansible/ansible.cfg'''. This file '''contains various settings''' such as the inventory file location, SSH connection options, privilege escalation rules, and more. Depending on the project you're working on, '''you can define a separate configuration''' file in a '''different directory with custom settings'''. This is one way to override specific parameters in Ansible without changing the global config.
 
In addition to the configuration file, you can create a '''playbook''', written in '''YAML'''. A playbook '''describes what tasks to run on which hosts'''. It typically defines target hosts, tasks to execute, roles to apply, variables, handlers, and other automation logic.
 
Be careful, when '''running a playbook''', you should explicitly '''specify''' which '''configuration file to use''' by setting it through an environment variable, or directly in the Playbook file :
 
<pre class="linux">
marijan$ ANSIBLE_CONFIG=/path/to/ansible.cfg ansible-playbook playbook.yml
</pre>

Version du 14 avril 2025 à 20:18

Introduction

Ansible Banner.png

Ansible is an open-source automation and orchestration tool based on YAML and SSH, used to automate repetitive tasks in infrastructure management, such as provisioning, configuration management, continuous delivery, application deployment, and security compliance.

Developing scripts for these tasks requires time, coding skills, and ongoing maintenance. With Ansible, automation becomes simple and efficient

Configuration Files and Playbook

Ansible provides a default configuration file, usually located at /etc/ansible/ansible.cfg. This file contains various settings such as the inventory file location, SSH connection options, privilege escalation rules, and more. Depending on the project you're working on, you can define a separate configuration file in a different directory with custom settings. This is one way to override specific parameters in Ansible without changing the global config.

In addition to the configuration file, you can create a playbook, written in YAML. A playbook describes what tasks to run on which hosts. It typically defines target hosts, tasks to execute, roles to apply, variables, handlers, and other automation logic.

Be careful, when running a playbook, you should explicitly specify which configuration file to use by setting it through an environment variable, or directly in the Playbook file :

marijan$ ANSIBLE_CONFIG=/path/to/ansible.cfg ansible-playbook playbook.yml