当前位置:网站首页>Ansible installation and use
Ansible installation and use
2022-07-02 04:52:00 【Floating foam*】
brief introduction :ansible It is a new automatic operation and maintenance tool , be based on Python Development , A collection of operations and maintenance tools (puppet、cfengine、chef、func、fabric) The advantages of , Realized batch system configuration 、 Batch program deployment 、 Batch run command and other functions .
This experiment is tested by three hosts , One of them acts as a management machine , The other two managed hosts
List of articles
One 、ansible install
1.1 install epel Extended source
yum install -y epel-release.noarch
1.2 install ansible
yum install -y ansible
see ansinle edition
After installation , There are many more ansible The command
Two 、 Configure the host
2.1 To configure hosts file
Add the information of the other two hosts
vi /etc/ansible/hosts
perform ansible command , In fact, in this case, the password is written in clear text in the configuration file , Do not apply
ansible 10.49.33.58 -m ping
The second configuration file is only one ip, To execute the command, enter the password , It is inconvenient to maintain multiple hosts
ansible 10.49.33.58 -m ping -k
Input password
The third case , Key management can be generated , No password required , Easy to manage
Production key
ssh-keygen
By default, the generated key is placed in /root/.ssh/
ll /root/.ssh
2.2 Management key
id_rsa It's the private key
id_rsa.pub It's the public key , You need to send the public key to the managed host
Usage mode :
ssh-copy-id [-i [identity_file] ] [[email protected]]machine
-i: Specify the public key file
Local ssh Install the public key file to the corresponding account of the remote host :
ssh-copy-id [email protected]
ssh-copy-id -i ~/.ssh/id_rsa.pub [email protected]
ssh-copy-id -i /root/.ssh/id_rsa.pub [email protected]10.49.33.58
After successful execution , We check on the target machine /root/.ssh The directory has been generated , And there is another one named authorized_keys The file of , What is stored in it is the original machine ssh-keygen Generated id_rsa.pub The content of
Try logging in as prompted 10.49.33.58
ssh [email protected]10.49.33.58
Go straight into , No more passwords
Empathy , Pass the public key to 10.49.33.59 in
ssh-copy-id -i /root/.ssh/id_rsa.pub [email protected]10.49.33.59
The relevant operation configuration of public key authentication is completed , Can pass ansible The host connects to these hosts without password , It greatly improves the security
2.3 Managed host grouping
You can also group different hosts , The default configuration file also has prompts
ansible test -m ping
thus , ordinary ansible Completion of construction management
3、 ... and 、ansible Composition Introduction
3.1 see ansible Directory file
tree /etc/ansible/
/etc/ansible/
├── ansible.cfg # The configuration file
├── hosts # Main warehouse Used to store information about remote hosts that need to be managed
└── roles # The directory where the characters are stored
3.2 Ansible Command parameter details
Ansible The command syntax is as follows :
ansible [-i Host files ] [-f batch ] [ Group name ] [-m Module name ] [-a Module parameters ]
Ansible The detailed parameters are as follows :
-i inventory_file—— Specifies the host file , If you don't specify , The default is /etc/ansible/hosts file , In the host file , Defined Ansible Host to control IP Or domain name , And its users 、 password
-f 10—— Indicates the number of synchronization processes specified to start
-m module—— Express Ansible Module to call
-a —— Specify the parameters of the module , It can be orders and so on
-sudo —— Said the use of ansible get sudo jurisdiction
-k —— Express ansible The use of SSH password
-u username—— To designate Ansible The executing user
-C —— Indicates command test
3.3 ansible Module function view
Ansible There are many modules , View all ansible Module , Use command :
ansible-doc -l
There are so many modules , On the left is the module name , On the right is the description of module functions
Check the function of a module in detail , And check its parameters , Can execute orders :
ansible-doc -s [ Module name ]
3.4 hosts file
hosts Files generally store our managed host information . Host list , Also called Inventory. All managed hosts need to be defined in this file . If you don't want to use the default list, you can use -i Option to specify a custom manifest file , Prevent multiple people from using a host list . If not defined in the host list file , Executing the command will prompt “No hosts matched”
thank you
边栏推荐
- Record the bug of unity 2020.3.31f1 once
- Solution: the agent throws an exception error
- Super detailed pycharm tutorial
- Research on the security of ognl and El expressions and memory horse
- 数学知识(欧拉函数)
- 正大美欧4的主账户关注什么数据?
- Flag bits in assembly language: CF, PF, AF, ZF, SF, TF, if, DF, of
- Pytest learning ----- pytest assertion of interface automation testing
- Mysql表insert中文变?号的问题解决办法
- Thinkphp内核工单系统源码商业开源版 多用户+多客服+短信+邮件通知
猜你喜欢
缓存一致性解决方案——改数据时如何保证缓存和数据库中数据的一致性
Let正版短信测压开源源码
UNET deployment based on deepstream
Vmware安装win10报错:operating system not found
农业生态领域智能机器人的应用
Landing guide for "prohibit using select * as query field list"
Cultivate primary and secondary school students' love for educational robots
How do I interview for a successful software testing position? If you want to get a high salary, you must see the offer
Learn what definitelytyped is through the typescript development environment of SAP ui5
Alibaba cloud polkit pkexec local rights lifting vulnerability
随机推荐
Thinkphp Kernel wo system source Commercial Open source multi - user + multi - Customer Service + SMS + email notification
[Yu Yue education] autumn 2021 reference materials of Tongji University
Mysql重点难题(2)汇总
Mouse events in JS
Orthogonal test method and function diagram method for test case design
Leetcode merge sort linked list
Ten thousand volumes are known to all, and one page of a book is always relevant. TVP reading club will take you through the reading puzzle!
Ruby replaces gem Alibaba image
Rhcsa --- work on the third day
C# 图片显示占用问题
数学知识(欧拉函数)
2022-003arts: recursive routine of binary tree
win10 磁盘管理 压缩卷 无法启动问题
Comp 250 parsing
geotrust ov多域名ssl证书一年两千一百元包含几个域名?
How to modify data file path in DM database
06 decorator mode
Free drawing software recommended - draw io
Getting started with pytest ----- confitest Application of PY
Learn what definitelytyped is through the typescript development environment of SAP ui5