当前位置:网站首页>[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!
边栏推荐
- OpenCL线程代数库ViennaCL的使用
- 企事业单位源代码防泄露工作该如何进行
- Today, Ali came out with 35K. It's really sandpaper that wiped my ass. it showed me my hand
- 8 ways to earn passive income
- [chestnut sugar GIS] global mapper - how to assign the elevation value of the grid to the point
- 86. separate linked list
- Sword finger offer 22 The penultimate node in the linked list
- /Path/to/ idiom, not a command
- Create uiactionsheet [duplicate] - creating uiactionsheet [duplicate]
- 09- [istio] istio service entry
猜你喜欢

Redistemplate common method summary

Why can transformer break into the CV world and kill CNN?

9. naive Bayes

Intelligent deodorizer embedded development

After getting these performance test decomposition operations, your test path will be more smooth

AI大模型落地大考,浪潮交出了怎样的答卷?

Xctf--Web--Challenge--area Wp

云服务器部署 Web 项目

Summary of redis learning notes (I)

How to judge the quality of network transformer? What symptom is network filter transformer broken?
随机推荐
After reading who moved my cheese
At the age of 32, I fell into a middle-aged crisis and finally quit naked...
电脑查看WiFi使用密码
Uboot reads the DDR memory size by sending 'R' characters through the terminal
Basic operations of C language
[Blue Bridge Road -- bug free code] DS1302 time module code analysis
86. separate linked list
Do you know how to show the health code in only 2 steps
8 ways to earn passive income
Sword finger offer 22 The penultimate node in the linked list
动态规划--怪盗基德的滑翔翼
Is it safe to open an account and trade with a compass?
24、 I / O device model (serial port / keyboard / disk / printer / bus / interrupt controller /dma and GPU)
14x1.5cm vertical label is a little difficult, VFP calls bartender to print
Learning about functions QAQ
Stack overflow caused by C # using protobuf stack overflow
Codeforces C. Andrew and Stones
Inno setup the simplest user-defined interface effect
Bev instance prediction based on monocular camera (iccv 2021)
Projet Web de déploiement du serveur Cloud