In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you how to install and deploy Ansible, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's learn about it!
I. Ansible principle
1.1 what is Ansible
Ansible is an open source platform / framework that integrates configuration management, application deployment, and specific tasks of IT systems. Based on Python language implementation, the core modules include: jinja2, PyYAML and paramiko. Ansible allows repeated execution without errors, with no agent on the client and no deamon process on the server. Ansible features:
Ansible supports API API calls, such as CMDB calls or public cloud interface calls
Ansible is a framework that works based on modules and plug-ins
Work based on SSH, that is, the managed side should support SSH management
Write powerful configuration and state management through playbooks to achieve automation
1.2 description of important components of Ansible
Module: Ansible consists of a variety of functional modules
Playbook:Ansible script, which uses yml syntax to call different functional modules to complete specific functions.
Roles:Ansbiel role, you can use the ansible-galaxy command to download the third party's roles role.
Ansible-vault: file encryption tool
Ansilbe-console: interact with users based on console
Ansible-doc: help documentation,-l all modules,-s brief help
1.3 Ansible implementation process and principle explanation
Load the configuration file, default is / etc/ansible/ansible.cfg
Load the corresponding module
Produce temporary py files and transfer them to the target machine's ~ / .ansible / tmp directory
Add + x permission to the py file, execute and return the result
Delete the py file and exit with sleep 0
1.4 Ansible execution status description
Green: successful implementation, no need to change
Yellow: successfully executed, make changes to the target host
Red: execution failed
II. Installation and configuration of Ansible
2.1 install Ansible
Install Ansible, taking CentOS 7.6 as an example:
[root@ansible ~] # cat / etc/redhat-release CentOS Linux release 7.6.1810 (Core) [root@ansible ~] # uname-a Linux ansible 3.10.0-957.el7.x86_64 # 1 SMP Thu Nov 8 23:39:32 UTC 2018 x86 "64 GNU/Linux# configure epel Source [root@ansible] # cat / etc/yum.repos.d/epel-7.repo [epel] name=Extra Packages for Enterprise Linux 7-$basearch baseurl= http://mirrors.aliyun.com/epel/7/$basearch failovermethod=priority enabled=1 gpgcheck=0 gpgkey= file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 [epel-debuginfo] name=Extra Packages for Enterprise Linux 7-$basearch-Debug baseurl= http://mirrors.aliyun.com/epel/7/$basearch/debug failovermethod=priority enabled=0 gpgkey= file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 gpgcheck=0 [epel-source] name=Extra Packages for Enterprise Linux 7-$basearch-Source baseurl= http://mirrors.aliyun.com/epel/7/SRPMS failovermethod=priority enabled=0 gpgkey= file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 gpgcheck=0# install Ansible [root@ansible ~] # yum install ansible-y # View the installed Ansible version [root@ansible ~] # ansible-- version ansible 2.8.2 config file = / etc/ansible/ansible.cfg configured module search path = [upright erythrootUnix.ansibleUniverse pluginsstop modules' Ansible python module location / usr/lib/python2.7/site-packages/ansible executable location = / usr/bin/ansible python version = 2.7.5 (default, Oct 30 2018) 23:45:53) [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] [root@ansible yum.repos.d] # ansible-2.8.2-1.el7.noarch View Ansible related files yum info ansiblerpm-qa ansiblerpm-ql ansibel | less
2.2 Ansible profile
The main configuration files and functions of Ansible are described as follows:
/ etc/ansible/ ├── ansible.cfg # Ansible main configuration file ├── hosts # to define the list of machines to be managed └── roles # this directory is used to define roles
Ansible profile
/ etc/ansible/ansible.cfg main parameters description
# disable obsolete parameter alarm deprecation_warnings=False # disable command alarm command_warnings=False # connection is not checked for the first time, cooperate with the following playbook to achieve password-free ssh login host_key_checking=False # set the number of parallel forks=40 # enable log _ path = / var/log/ansible.log # ssh timeout timeout = 30
2.3 hosts host list
The default hosts file / etc/ansible/hosts, the host being manipulated must be in the hosts host list.
Cd / etc/ansiblevim hosts # grouping [mons] # set host alias ceph-node-1 ansible_ssh_host= 172.16.93.1 [client] 172.16.93.1 mons 2222 # also supports domain name and hostname Finally, it is explained that IP # supports the regular expression [kvm_node_all] 172.16.93. [6:9] # sets the grouping host variable [kvm_node_all:vars] ansible_ssh_user=rootansible_ssh_pass=Efly1234ansible_ssh_port=22 # automatic meaning variable my_name=zhangsan # inheritance relationship of the host, which inherits all the parent variables [kvm_node_all:children] client
2.4Secret key authentication between Ansible management machine and managed machine (optional)
# generate key ssh-keygen# will get the following two files [root@ansible ~] # tree / root/.ssh/ / root/.ssh/ ├── id_rsa └── id_rsa.pub# to write the public key to the managed machine ssh-copy-id 192.168.199.5 or ssh-copy-id-I / root/.ssh/id_rsa.pub-p 22 root@192. 168.199.52 above are all the contents of the article "how to install and deploy Ansible" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.