当前位置:网站首页>[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!
边栏推荐
- MySQL advanced (Advanced SQL statement)
- 电脑查看WiFi使用密码
- Sound network, standing in the "soil" of the Internet of things
- Is it safe to open an account and trade with a compass?
- Digital signature——
- [GPU] basic operation of GPU (I)
- How does WPS cancel automatic numbering? Four options
- Create priority queue
- C语言基础小操作
- UE4_ Editor UMG close window cannot destroy UMG immediately
猜你喜欢

9. naive Bayes

Solitidy - fallback 回退函数 - 2种触发执行方式

Delete the repeating elements in the sorting list (simple questions)

1380. lucky numbers in matrices

Idea of capturing mobile terminal variant combination

Transfer the token on the matic-erc20 network to the matic polygon

The average salary of software testing in 2022 has been released. Have you been averaged?

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

Rotating frame target detection mmrotate v0.3.1 training dota data set (II)

How to prevent source code leakage in enterprises and institutions
随机推荐
超简单 STM32 RTC闹钟 时钟配置
Use the code cloud publicholiday project to determine whether a day is a working day
Answer sheet for online assignment of "motor and drive" of Xijiao 21 autumn (IV) [standard answer]
Detailed explanation of issues related to SSL certificate renewal
Basic operations of C language
Solidity - Security - reentrancy attack
【板栗糖GIS】global mapper—如何把栅格的高程值赋予给点
旋转框目标检测mmrotate v0.3.1 训练DOTA数据集(二)
Word frequency statistics (string, list)
Xi'an Jiaotong 21st autumn economics online homework answer sheet (III) [standard answer]
Online assignment of C language program design in the 22nd spring of Western Polytechnic University
Shenzhou ares tx6 boot logo modification tutorial
9. naive Bayes
Inno setup the simplest user-defined interface effect
1380. lucky numbers in matrices
Use of OpenCL thread algebra library viennacl
Do you know how to show the health code in only 2 steps
云服务器部署 Web 项目
MySQL advanced (Advanced SQL statement)
How to prevent source code leakage in enterprises and institutions