当前位置:网站首页>Inventory host list in ansible (I wish you countless flowers and romance)
Inventory host list in ansible (I wish you countless flowers and romance)
2022-07-07 04:57:00 【Steve lu】
List of articles
Preface
This blog mainly explains Ansible Related configuration knowledge of host list
One 、inventory Host list
Inventory Support grouping hosts , Multiple hosts can be defined in each group , Each host can be defined in any one or more host groups .
If it's a host with a similar name , You can use a list to represent each host
vim /etc/ansible/hosts
[dbservers]
192.168.109.131:2222 # Define the remote connection port after the colon , The default is ssh Of 22 port
192.168.109.13[1:3] # The scope is :192.168.109.131 To 192.168.109.133
[[email protected] ansible]# ansible dbservers -a 'date'
192.168.109.133 | CHANGED | rc=0 >>
2022 year 07 month 06 Japan Wednesday 14:43:18 CST
192.168.109.132 | CHANGED | rc=0 >>
2022 year 07 month 06 Japan Wednesday 14:43:18 CST
192.168.109.131 | CHANGED | rc=0 >>
2022 year 07 month 06 Japan Wednesday 14:43:18 CST
[dbservers]
db-[a:f].example.org # Host name matching is supported a~f
1.1 inventory The variables in the
Inventory Variable name | meaning |
---|---|
ansible_host | ansible When connecting nodes IP Address |
ansible_port | The port number of the other party ,ssh even It defaults to 22 |
ansible_user | The host name used when connecting to the other host . When not specified , Will use to execute ansible or ansible-playbook Users of commands |
ansible_passwd | The name of the user when connecting ssh password , Valid only if key pair authentication is not used |
ansible_ssh_private_key_file | Specify key authentication ssh Private key file when connecting |
ansible_ssh_common_args | Provide to ssh、sftp、 scp life Make additional parameters |
ansible_become | Permission escalation is allowed |
ansible_become_method | Specify how to raise permissions , For example, you can use sudo/su/runas Methods such as |
ansible_become_user | To which user , Default promotion is root |
ansible_become_password | The password when promoting to the specified user permission |
1.2 Host variables
# Modify the managed client 192.168.109.134 ssh The configuration file 17 Line to modify the port number
systemctl stop firewalld.service
setenforce 0
vim /etc/ssh/sshd_config
Port 2222
systemctl restart sshd
# I haven't configured password free login for this client
# modify Ansible Manage the server host inventory configuration file
vim /etc/ansible/hosts
[lhq]
192.168.109.134 ansible_port=2222 ansible_user=root ansible_password=123123
# Write the password directly to the configuration without establishing , unsafe
ansible dbservers -a 'date'
1.3 Group variable
# Delete the existing password free login key file of the client
# Client configuration
cd
cd .ssh/
rm -rf authorized_keys
#ansible Configuration of control end
vim /etc/ansible/hosts
[webservers]
192.168.109.131
192.168.109.132
192.168.109.133
[webservers:vars]
# Expressed as webservers All hosts in the group define variables
ansible_user=root
ansible_password=123456
[[email protected] ansible]# ansible webservers -a 'date'
192.168.109.132 | CHANGED | rc=0 >>
2022 year 07 month 06 Japan Wednesday 17:34:46 CST
192.168.109.134 | CHANGED | rc=0 >>
2022 year 07 month 06 Japan Wednesday 17:34:46 CST
192.168.109.133 | CHANGED | rc=0 >>
2022 year 07 month 06 Japan Wednesday 17:34:46 CST
192.168.109.131 | CHANGED | rc=0 >>
2022 year 07 month 06 Japan Wednesday 17:34:46 CST
1.4 Group nesting
vim /etc/ansible/hosts
[webservers]
192.168.239.20
192.168.239.30
192.168.239.40
[webservers:vars]
ansible_user=root
ansible_password=1999612
[dbservers]
192.168.239.50:2222 ansible_user=root ansible_password=1999612
[webservers1:children]
webservers
dbserers
# Expressed as webservers1 The host group contains webservers Group and dbservers All hosts in the group
边栏推荐
- Some understandings about 01 backpacker
- What if the win11 screenshot key cannot be used? Solution to the failure of win11 screenshot key
- JS input and output
- STM32F103ZE+SHT30检测环境温度与湿度(IIC模拟时序)
- Servicemesh mainly solves three pain points
- Fiance donated 500million dollars to female PI, so that she didn't need to apply for projects, recruited 150 scientists, and did scientific research at ease!
- Zhou Yajin, a top safety scholar of Zhejiang University, is a curiosity driven activist
- 【数模】Matlab allcycles()函数的源代码(2021a之前版本没有)
- 当 Knative 遇见 WebAssembly
- Analyse approfondie de kubebuilder
猜你喜欢
Vscode 如何使用内置浏览器?
Gavin teacher's perception of transformer live class - rasa project actual combat e-commerce retail customer service intelligent business dialogue robot microservice code analysis and dialogue experim
Vscode automatically adds a semicolon and jumps to the next line
Local tool [Navicat] connects to remote [MySQL] operation
acwing 843. n-皇后问题
【Android Kotlin协程】利用CoroutineContext实现网络请求失败后重试逻辑
九章云极DataCanvas公司摘获「第五届数字金融创新大赛」最高荣誉!
Have you got the same "artifact" of cross architecture development praised by various industry leaders?
Pointer and array are input in function to realize reverse order output
[hand torn STL] list
随机推荐
Jetson nano配置pytorch深度学习环境//待完善
Flask项目使用flask-socketio异常:TypeError: function() argument 1 must be code, not str
Gavin teacher's perception of transformer live class - rasa project actual combat e-commerce retail customer service intelligent business dialogue robot microservice code analysis and dialogue experim
Wechat can play the trumpet. Pinduoduo was found guilty of infringement. The shipment of byte VR equipment ranks second in the world. Today, more big news is here
In depth analysis of kubebuilder
Code source de la fonction [analogique numérique] MATLAB allcycles () (non disponible avant 2021a)
【736. Lisp 语法解析】
深入解析Kubebuilder
Is there any way to bookmark the code in the visual studio project- Is there a way to bookmark code in a Visual Studio project?
What if the win11 screenshot key cannot be used? Solution to the failure of win11 screenshot key
What work items do programmers hate most in their daily work?
Canteen user dish relationship system (C language course design)
【Android Kotlin协程】利用CoroutineContext实现网络请求失败后重试逻辑
Gpt-3 is a peer review online when it has been submitted for its own research
Web3 社区中使用的术语
Why do many people misunderstand technical debt
指针与数组在函数中输入实现逆序输出
Function pointer and pointer function in C language
JDBC link Oracle reference code
Introduction to namespace Basics