当前位置:网站首页>[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 = False
Before#
Number , Disable every execution ansible Command check ssh key host - Get rid of
log_path = /var/log/ansible.log
Before#
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
inventory
The contents of the document
[all]
localhost
Refer to the figure
all.yml
The 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!
边栏推荐
- Xiaosha's lunch
- 云服务器部署 Web 项目
- UML tools
- Luogup2756 pilot pairing scheme problem (maximum flow)
- Xctf--Web--Challenge--area Wp
- Rotating frame target detection mmrotate v0.3.1 learning configuration
- How to create a CSR (certificate signing request) file?
- The average salary of software testing in 2022 has been released. Have you been averaged?
- Related applications of priority queue
- Cisco VXLAN配置
猜你喜欢
STM32F103系列控制的OLED IIC 4针
【LeetCode】236. Nearest common ancestor of binary tree
Finally someone can make the server so straightforward
How to judge the quality of network transformer? What symptom is network filter transformer broken?
[chestnut sugar GIS] global mapper - how to assign the elevation value of the grid to the point
What kind of answer has Inspur given in the big AI model landing test?
Using lazy < t > in C # to realize singleton mode in WPF
Database SQL language 04 subquery and grouping function
Xctf--Web--Challenge--area Wp
剑指 Offer 22. 链表中倒数第k个节点
随机推荐
PKCs 12:personal information exchange syntax v1.1 translation part I
How to write a thesis
Dynamic programming -- gliding wing of the strange thief Kidd
领导:谁再用 Redis 过期监听实现关闭订单,立马滚蛋!
Do you know how to show the health code in only 2 steps
Navigate back to fragmentpageradapter - & gt; Fragment is empty - navigating back to fragmentpageradapter - & gt; fragments are empty
1380. lucky numbers in matrices
What are membrane stress and membrane strain
Xctf--Web--Challenge--area Wp
Shenzhou ares tx6 boot logo modification tutorial
Use the code cloud publicholiday project to determine whether a day is a working day
English语法_形容词/副词3级-最高级
leetcode763. Divide letter interval
Video summary of my station B
Rotating frame target detection mmrotate v0.3.1 learning configuration
云服务器部署 Web 项目
24、 I / O device model (serial port / keyboard / disk / printer / bus / interrupt controller /dma and GPU)
InputStream转InputStreamSource
Online assignment of C language program design in the 22nd spring of Western Polytechnic University
Transfer the token on the matic-erc20 network to the matic polygon