3. Writing and basic variables of ansible-iventory

Ansible's configuration file needs to be considered a little bit. For some settings, such as ssh ports, users, threads, try to adjust the
iventory in /etc/ansible/hosts. Regular matching can be used in
ansible. From the beginning of the inventory, I will tell you from the inventory. Up
1. The basic composition of the hosts file is that hosts hosts can form a group, that is, a group, and a group can form a large group
----------------------- -------------------------------------------------- ---
[atlanta]
host1
host2
[raleigh]
host2
host3
[southeast:children]
atlanta
raleigh
------------------------------ --------------------------------------------------
2.hosts can have their own variable group can set common variables
----------------------------------- ---------------------------------------------
[atlanta]
host1 http_port =80 maxRequestsPerChild=808
host2 http_port=303 maxRequestsPerChild=909
[atlanta]
host1
host2
[atlanta:vars]
ntp_server=ntp.atlanta.example.com
proxy=proxy.atlanta.example.com
--------------- -------------------------------------------------- ---------------
3. There are two ways of writing list and yml
4. inventory supports matching
-------------------- -------------------------------------------------- ----------
[webservers]
www[01:50].example.com
[databases]
db-[a:f].example.com
------------- -------------------------------------------------- -----------------
5. By default, there is an all group that contains all hosts
6. We can also record our variables in the form of files
---------- -------------------------------------------------- --------------------
/etc/ansible/group_vars/raleigh # can optionally end in '.yml', '.yaml', or '.json'
/etc/ansible/group_vars/webservers
/etc/ansible/host_vars/foosball
------ -------------------------------------------------- ------------------------
---
ntp_server: acme.example.org
database_server: storage.example.org
--------- -------------------------------------------------- ---------------------
7. COMMON VARIABLES
----------------------- -------------------------------------------------- ------
ansible_host
ansible_port
ansible_user
ansible_ssh_pass Usually do not use plaintext, use vault (I don't know)
ansible_ssh_private_key_file
ansible_ssh_executable
This setting overrides the default behavior to use the system ssh. This can override the ssh_executable setting in ansible.cfg.

ansible_become
ansible_become_method
ansible_become_user
ansible_become_pass
ansible_shell_type
--------------------------------------------- -----------------------------------
8. Ansible and cobbler can also manage dynamic inventory with batch installation tools It is very complicated, and it is not used much in the cloud environment.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325374370&siteId=291194637