Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Inventory host list and variable introduction

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

The knowledge points of this article include the host list of inventory and the introduction of inventory variables. Knowledge points are often used by everyone, so I will share them for you as a reference. Let's follow the editor and have a look.

Inventory host list ansible default host list is / etc/ansible/hosts file host list can be set manually, or you can dynamically generate a general host name through Dynamic Inventory. Use FQDNvi / etc/ansible/hosts [webserver] # square brackets to set the group name www1.example.org # to define the monitored host, which can be either the host name or the IP address The hostname needs to be modified / etc/hosts file www2.example.org:2222 # define the remote connection port after the colon. The default is port 22 of ssh. If it is a host with a similar name, you can use a list to identify each host [webserver] www [01:50] .example.org ansible_ssh_user=root ansible_ssh_pass= 123456 [dbbservers] db- [aRAF] .example.org is the variable in Inventory.

(1) Host variable

[webserver] www1.magedu.com http_port=80 maxRequestsChild=808www2.magedu.com http_port=8080 maxRequestsChild=909 (2) group variable [servers:vars] ntp_server=ntp.example.orgnfs_server=nfs.example.org (3) group nesting [apache] htt p1.example.orghttp2.example.org [ngx1.example.orgngx2.example.orgngx2.example.org [webservers: children] apachenginx (4) the inventory variable parameter indicates the remote host name to which the ansible_ssh_host will connect. If it is different from the alias of the host you want to set, you can set the .ansible _ ssh_port ssh port number through this variable. If it is not the default port number, use this variable to set the .ansible _ ssh_user default ssh username ansible_ssh_pass ssh password (this is not secure, we strongly recommend using-- ask-pass or SSH key) the private key file used by ansible_ssh_private_key_file ssh. Applies if you have multiple keys and you do not want to use the SSH proxy. Ansible_ssh_common_args this setting is attached to the default command line ansible _ sftp_extra_args for sftp,scp and ssh. This setting is attached to the default sftp command line. Ansible_scp_extra_args this setting is attached to the default scp command line. Ansible_ssh_extra_args this setting is attached to the default ssh command line. Ansible_ssh_pipelining determines whether to use SSH pipes. This can override the settings in ansible.cfg. The shell type of the ansible_shell_type target system. By default, the command is executed using the 'sh' syntax and can be set to the python path of the target host' csh' or 'fish'.ansible_python_interpreter. Applicable: there are multiple Python in the system, or the command path is not "/ usr/bin/python", such as * BSD, or / usr/bin/pythonansible_*_interpreter. The "*" here can be an interpreter of ruby or perl or other languages, acting like ansible_python_interpreter, which is similar to ansible_shell_executable. This will set the shell that the ansible controller will use on the target machine, overriding the configuration in ansible.cfg, and defaults to / bin/sh.

After reading the above, do you have any further understanding of the inventory host list and variables? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report