A file for managing the server you are working on. Ansible automatically adds localhost to your inventory by default, so Connect directly to localhost without making an SSH connection.
The default value can be overridden with [default] in the ansible.cfg file. ansible_ssh_host ** default: host name ** Host name / IP address to connect to SSH ansible_ssh_port default: 22 Port to connect to SSH ansible_ssh_user default: root SSH user ansible_ssh_pass ** default: none ** Password used for SSH authentication ansible_connection default: smart How Ansible connects to the host ansible_ssh_private_key_file ** default: none ** Private key used for SSH authentication ansible_shell_type default: sh Shell used to execute commands Besides, csh, fish, powershell can be used. (I don't use it much) ansible_python_interpreter default: /usr/bin/python Python interpreter on host Since the Ansible module is implemented in Python2, If the remote host Python2 interpreter is not in / usr / bin / python You need to change this value. ansible_*_interpreter ** default: none ** Interpreter settings for other languages
ansible automatically for all hosts in the all (or *) inventory Tasks are executed, but it is also possible to divide them into groups and execute tasks as shown below.
inventory
[target1]
host1
host2
host3
[target2]
host4
host5
It is also possible to create a group of groups as shown below.
inventory
[all host]
target1
target2
Ansible can add hosts and groups to the inventory while the playbook is running. add_host Add the host to the inventory. It can be used, for example, when using Ansible to provision a new virtual machine instance in the Iaas type cloud. group_by You can create a new group while the playbook is running.
** Related materials **
Introduction to Ansible (1)'Hello World'
Introduction to Ansible Part 2'Basic Grammar'
** References **
First Ansible (written by Lorin Hochstein, translated by Ryuji Tamagawa, O'Reilly Japan Co., Ltd.)
Recommended Posts