当前位置:网站首页>[ansible series] fundamentals -01
[ansible series] fundamentals -01
2022-06-30 05:51:00 【Pie Daxing's good friend Dingdang cat】
List of articles
1. brief introduction
- Ansible Tracing to the source
Ansible From science fiction , It is a fictitious communication device that transmits information at the speed of Superlight . - Ansible What is it? ?
Ansible It is a modular automatic operation and maintenance tool , be based on python Language implementation , from Paramiko,PyYAML and Jinjia2 It consists of three key modules .Ansible Supports multi node publishing 、 Remote task execution , By default SSH Make a remote connection . - Ansible Basic framework

Ansible The composition of the basic architecture :
Host Inventory: Host list , Definition ansible Managed hosts
Playbooks: Script ,ansible Task configuration file for , Define multiple tasks in the script ,ansible Automatic execution
Ansible: The core
Core Module: Core module ,ansible Bring their own
Custom Module: Extension module , If the core module is not enough to accomplish some function , You can add expansion modules
Plugins: Complete the supplement of module function
Connection Plugins:ansible By default ssh Connect to each host , But other connection methods are also supported
2.Ansible install
The main installation methods are as follows 4 Kind of
- Method 1:yum install
yum install epel-release
yum install ansible
- Method 2:pip install
pip install ansible
- Method 3:brew install
brew install ansible
- Method 4: Source code installation (mac recommend )
git clone https://github.com/ansible/ansible.git
cd ansible
sudo python setup.py install
After installation , Use ansible --version Check if the installation is successful
The installation succeeds when the version information is displayed , Here's the picture
Refer to the figure 
3. To configure SSH secret key ( Secret free connection of controlled host )
Test environment : CentOS Linux release 7.7.1908 (Core)
The test is conducted locally , That is, both the control host and the controlled host are localhost
- Generate key file
ssh-keygen
ssh-keygen No parameters after , Default generation rsa Type key file , If the following box appears, the key generation is successful . Key file in /root/.ssh Under the table of contents .
Refer to the figure 
- Password free login
After generating the key file, enter , Following commands , You need to enter the password once during
ssh-copy-id localhost
Refer to the figure 
It's going on ssh localhost when , You no longer need to enter a password , Direct access to
4. ansible The configuration file
- modify ansible.cfg The configuration file
Ansible Profile location/etc/ansible/ansible.cfg
Configuration file changes- Get rid of
host_key_checking = FalseBefore#Number , Disable every execution ansible Command check ssh key host - Get rid of
log_path = /var/log/ansible.logBefore#Number , Log on
- Get rid of
5. test
5.1 The test sample 1
stay /etc/ansible/hosts end of file , add to localhost, Save file exit
Refer to the figure 
Enter the following command to perform the connectivity test
ansible all -m ping
The test results are as follows :
5.2 The test sample 2
This sample implements a ansible Version of Hello World!
Create a new directory , Create... In this directory inventory and all.yml Two documents
inventoryThe contents of the document
[all]
localhost
Refer to the figure 
all.ymlThe contents of the document
---
- name: debug Hello World
hosts: all
gather_facts: no
tasks:
- name: debug
debug:
Refer to the figure 
- function
ansible-playbook -i inventory all.yml
The output results are shown in the figure below 
msg Medium output Hello World!
边栏推荐
- luoguP2756 飞行员配对方案问题(最大流)
- Learning about functions QAQ
- Intelligent deodorizer embedded development
- Turn off automatic outlining in Visual Studio - turning off automatic outlining in Visual Studio
- 1380. lucky numbers in matrices
- Digital signature——
- Rotating frame target detection mmrotate v0.3.1 training dota data set (II)
- Related applications of priority queue
- Projet Web de déploiement du serveur Cloud
- Vfpbs uploads excel and saves MSSQL to the database
猜你喜欢

Dao -- a beautiful new world?

MySQL高级SQL语句

OSPF - authentication and load balancing summary (including configuration commands)

1380. lucky numbers in matrices

Today, Ali came out with 35K. It's really sandpaper that wiped my ass. it showed me my hand

聲網,站在物聯網的“土壤”裏

Tornado frame foundation

Leetcode56. consolidation interval

How to judge the quality of network transformer? What symptom is network filter transformer broken?

How to automatically renew a token after it expires?
随机推荐
炒股用指南针开户交易安全吗?
After getting these performance test decomposition operations, your test path will be more smooth
[secretly kill little partner pytorch20 days] - [day4] - [example of time series data modeling process]
Sword finger offer 29 Print matrix clockwise
How to write a thesis
Answer sheet for online assignment of "motor and drive" of Xijiao 21 autumn (IV) [standard answer]
Switch to software testing and report to the training class for 3 months. It's a high paying job. Is it reliable?
InputStream转InputStreamSource
Array pointers and pointer arrays
Use of tornado template
El table lazy load refresh
Leetcode56. consolidation interval
Who is promoting the new inflection point of audio and video industry in 2022?
Dao -- a beautiful new world?
Rotating frame target detection mmrotate v0.3.1 learning configuration
Golden code of programmer interview
09- [istio] istio service entry
[GPU] basic operation of GPU (I)
UE4_ Editor UMG close window cannot destroy UMG immediately
Sound network, standing in the "soil" of the Internet of things