标签:comm nsa ack 配置文件 erp Opens paramiko summary playbook
Ansible是一款自动化运维工具,基于Python开发,集合了众多运维工具(puppet、cfengine、chef、func、fabric)的优点,实现了批量系统配置、批量程序部署、批量运行命令等功能。
Ansible是基于模块工作的,本身没有批量部署的能力。真正具有批量部署的是Ansible所运行的模块,Ansible只是提供一种框架。主要包括:
(1) 连接插件connection plugins:负责和被监控端实现通信;
(2) host inventory:指定操作的主机,是一个配置文件里面定义监控的主机;
(3) 各种模块核心模块、command模块、自定义模块;
(4) 借助于插件完成记录日志邮件等功能;
(5) playbook:剧本执行多个任务时,非必需可以让节点一次性运行多个任务。
Ansible架构图:
Ansible 围绕无代理架构构建。通常而言,Ansible 通过 OpenSSH 或 WinRM 连接它所管理的主机并且运行任务,方法通常是将称为 Ansible 模块的小程序推送至这些主机。这些程序用于将系统置于需要的特定状态。在 Ansible 运行完其任务后,推送的所有模块都会被删除。
Ansible 不需要批准使用任何特殊代理,然后再部署到受管主机上。由于没有代理,也不需要额外的自定义安全基础架构,
Ansible 具有多个重要的优点:
Ansible 的设计宗旨是工具易用,自动化易写易读。所以在创建自动化时我们应追求简单化。
Ansible 自动化语言围绕简单易读的声明性文本文件来构建。正确编写的 Ansible Playbook可以清楚地记录你的工作自动化。
Ansible 是一种要求状态引擎。它通过表达你所希望系统处于何种状态来解决如何自动化IT部署的问题。Ansible 的目标是通过仅执行必要的更改,使系统处于所需的状态。试图将 Ansible 视为脚本语言并非正确的做法。
本次环境YUM源(centos和epel)为:"阿里云官方镜像站"
//配置centos源 [root@localhost ~]# rm -rf /etc/yum.repos.d/* [root@localhost ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo [root@localhost ~]# sed -i -e ‘/mirrors.cloud.aliyuncs.com/d‘ -e ‘/mirrors.aliyuncs.com/d‘ /etc/yum.repos.d/CentOS-Base.repo [root@localhost ~]# sed -i ‘s|$releasever|8|‘ /etc/yum.repos.d/CentOS-Base.repo //配置epel源 [root@localhost ~]# yum install -y https://mirrors.aliyun.com/epel/epel-release-latest-8.noarch.rpm [root@localhost ~]# sed -i ‘s|^#baseurl=https://download.fedoraproject.org/pub|baseurl=https://mirrors.aliyun.com|‘ /etc/yum.repos.d/epel* [root@localhost ~]# sed -i ‘s|^metalink|#metalink|‘ /etc/yum.repos.d/epel* [root@localhost ~]# sed -i ‘s|$releasever|8|‘ /etc/yum.repos.d/epel* [root@localhost ~]# yum clean all [root@localhost ~]# yum makecache [root@localhost ~]# ls /etc/yum.repos.d/ CentOS-Base.repo epel-playground.repo epel-testing-modular.repo epel-modular.repo epel.repo epel-testing.repo [root@localhost ~]# ls /etc/yum.repos.d/ CentOS-Base.repo epel-playground.repo epel-testing-modular.repo epel-modular.repo epel.repo epel-testing.repo 安装ansible [root@localhost ~]# yum -y install ansible CentOS-8 - Base - mirrors.aliyun.com 18 kB/s | 3.9 kB 00:00 CentOS-8 - Extras - mirrors.aliyun.com 8.9 kB/s | 1.5 kB 00:00 CentOS-8 - AppStream - mirrors.aliyun.com 17 kB/s | 4.3 kB 00:00 Extra Packages for Enterprise Linux Modular 8 - x86_64 12 kB/s | 3.0 kB 00:00 Extra Packages for Enterprise Linux 8 - x86_64 20 kB/s | 4.7 kB 00:00 Extra Packages for Enterprise Linux 8 - x86_64 3.3 MB/s | 8.7 MB 00:02 Dependencies resolved. ======================================================================================================= Package Arch Version Repository Size ======================================================================================================= Installing: ansible noarch 2.9.16-1.el8 epel 17 M Upgrading: platform-python-pip noarch 9.0.3-18.el8 base 1.7 M platform-python-setuptools noarch 39.2.0-6.el8 base 632 k Installing dependencies: python3-pyyaml x86_64 3.12-12.el8 base 193 k python3-setuptools noarch 39.2.0-6.el8 base 163 k python3-babel noarch 2.5.1-5.el8 AppStream 4.8 M python3-jinja2 noarch 2.10.1-2.el8_0 AppStream 538 k python3-jmespath noarch 0.9.0-11.el8 AppStream 45 k python3-markupsafe x86_64 0.23-19.el8 AppStream 39 k python3-pip noarch 9.0.3-18.el8 AppStream 20 k python3-pyasn1 noarch 0.3.7-6.el8 AppStream 126 k python3-pytz noarch 2017.2-9.el8 AppStream 54 k python36 x86_64 3.6.8-2.module_el8.3.0+562+e162826a AppStream 19 k libsodium x86_64 1.0.18-2.el8 epel 162 k python3-bcrypt x86_64 3.1.6-2.el8.1 epel 44 k python3-pynacl x86_64 1.3.0-5.el8 epel 100 k sshpass x86_64 1.06-9.el8 epel 27 k Installing weak dependencies: python3-paramiko noarch 2.4.3-1.el8 epel 289 k Enabling module streams: python36 3.6 Transaction Summary ======================================================================================================= Install 16 Packages Upgrade 2 Packages Total download size: 26 M Downloading Packages: (1/18): python3-pyyaml-3.12-12.el8.x86_64.rpm 917 kB/s | 193 kB 00:00 (2/18): python3-setuptools-39.2.0-6.el8.noarch.rpm 567 kB/s | 163 kB 00:00 (3/18): python3-jmespath-0.9.0-11.el8.noarch.rpm 233 kB/s | 45 kB 00:00 (4/18): python3-markupsafe-0.23-19.el8.x86_64.rpm 312 kB/s | 39 kB 00:00 (5/18): python3-pip-9.0.3-18.el8.noarch.rpm 111 kB/s | 20 kB 00:00 (6/18): python3-jinja2-2.10.1-2.el8_0.noarch.rpm 763 kB/s | 538 kB 00:00 (7/18): python3-pyasn1-0.3.7-6.el8.noarch.rpm 450 kB/s | 126 kB 00:00 (8/18): python3-pytz-2017.2-9.el8.noarch.rpm 272 kB/s | 54 kB 00:00 (9/18): python36-3.6.8-2.module_el8.3.0+562+e162826a.x86_64.rpm 109 kB/s | 19 kB 00:00 (10/18): python3-babel-2.5.1-5.el8.noarch.rpm 3.8 MB/s | 4.8 MB 00:01 (11/18): python3-bcrypt-3.1.6-2.el8.1.x86_64.rpm 252 kB/s | 44 kB 00:00 (12/18): libsodium-1.0.18-2.el8.x86_64.rpm 650 kB/s | 162 kB 00:00 (13/18): python3-paramiko-2.4.3-1.el8.noarch.rpm 1.0 MB/s | 289 kB 00:00 (14/18): python3-pynacl-1.3.0-5.el8.x86_64.rpm 332 kB/s | 100 kB 00:00 (15/18): sshpass-1.06-9.el8.x86_64.rpm 148 kB/s | 27 kB 00:00 (16/18): platform-python-pip-9.0.3-18.el8.noarch.rpm 2.4 MB/s | 1.7 MB 00:00 (17/18): platform-python-setuptools-39.2.0-6.el8.noarch.rpm 1.0 MB/s | 632 kB 00:00 (18/18): ansible-2.9.16-1.el8.noarch.rpm 4.8 MB/s | 17 MB 00:03 ------------------------------------------------------------------------------------------------------- Total 5.6 MB/s | 26 MB 00:04 Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Upgrading : platform-python-setuptools-39.2.0-6.el8.noarch 1/20 Installing : python3-setuptools-39.2.0-6.el8.noarch 2/20 Upgrading : platform-python-pip-9.0.3-18.el8.noarch 3/20 Installing : python3-pip-9.0.3-18.el8.noarch 4/20 Installing : python36-3.6.8-2.module_el8.3.0+562+e162826a.x86_64 5/20 Running scriptlet: python36-3.6.8-2.module_el8.3.0+562+e162826a.x86_64 5/20 Installing : sshpass-1.06-9.el8.x86_64 6/20 Installing : python3-bcrypt-3.1.6-2.el8.1.x86_64 7/20 Installing : libsodium-1.0.18-2.el8.x86_64 8/20 Installing : python3-pynacl-1.3.0-5.el8.x86_64 9/20 Installing : python3-pytz-2017.2-9.el8.noarch 10/20 Installing : python3-babel-2.5.1-5.el8.noarch 11/20 Installing : python3-pyasn1-0.3.7-6.el8.noarch 12/20 Installing : python3-paramiko-2.4.3-1.el8.noarch 13/20 Installing : python3-markupsafe-0.23-19.el8.x86_64 14/20 Installing : python3-jinja2-2.10.1-2.el8_0.noarch 15/20 Installing : python3-jmespath-0.9.0-11.el8.noarch 16/20 Installing : python3-pyyaml-3.12-12.el8.x86_64 17/20 Installing : ansible-2.9.16-1.el8.noarch 18/20 Cleanup : platform-python-pip-9.0.3-15.el8.noarch 19/20 Cleanup : platform-python-setuptools-39.2.0-5.el8.noarch 20/20 Running scriptlet: platform-python-setuptools-39.2.0-5.el8.noarch 20/20 Verifying : python3-pyyaml-3.12-12.el8.x86_64 1/20 Verifying : python3-setuptools-39.2.0-6.el8.noarch 2/20 Verifying : python3-babel-2.5.1-5.el8.noarch 3/20 Verifying : python3-jinja2-2.10.1-2.el8_0.noarch 4/20 Verifying : python3-jmespath-0.9.0-11.el8.noarch 5/20 Verifying : python3-markupsafe-0.23-19.el8.x86_64 6/20 Verifying : python3-pip-9.0.3-18.el8.noarch 7/20 Verifying : python3-pyasn1-0.3.7-6.el8.noarch 8/20 Verifying : python3-pytz-2017.2-9.el8.noarch 9/20 Verifying : python36-3.6.8-2.module_el8.3.0+562+e162826a.x86_64 10/20 Verifying : ansible-2.9.16-1.el8.noarch 11/20 Verifying : libsodium-1.0.18-2.el8.x86_64 12/20 Verifying : python3-bcrypt-3.1.6-2.el8.1.x86_64 13/20 Verifying : python3-paramiko-2.4.3-1.el8.noarch 14/20 Verifying : python3-pynacl-1.3.0-5.el8.x86_64 15/20 Verifying : sshpass-1.06-9.el8.x86_64 16/20 Verifying : platform-python-pip-9.0.3-18.el8.noarch 17/20 Verifying : platform-python-pip-9.0.3-15.el8.noarch 18/20 Verifying : platform-python-setuptools-39.2.0-6.el8.noarch 19/20 Verifying : platform-python-setuptools-39.2.0-5.el8.noarch 20/20 Upgraded: platform-python-pip-9.0.3-18.el8.noarch platform-python-setuptools-39.2.0-6.el8.noarch Installed: ansible-2.9.16-1.el8.noarch python3-paramiko-2.4.3-1.el8.noarch python3-pyyaml-3.12-12.el8.x86_64 python3-setuptools-39.2.0-6.el8.noarch python3-babel-2.5.1-5.el8.noarch python3-jinja2-2.10.1-2.el8_0.noarch python3-jmespath-0.9.0-11.el8.noarch python3-markupsafe-0.23-19.el8.x86_64 python3-pip-9.0.3-18.el8.noarch python3-pyasn1-0.3.7-6.el8.noarch python3-pytz-2017.2-9.el8.noarch python36-3.6.8-2.module_el8.3.0+562+e162826a.x86_64 libsodium-1.0.18-2.el8.x86_64 python3-bcrypt-3.1.6-2.el8.1.x86_64 python3-pynacl-1.3.0-5.el8.x86_64 sshpass-1.06-9.el8.x86_64 Complete! [root@localhost ~]# ansible --version ansible 2.9.16 config file = /etc/ansible/ansible.cfg configured module search path = [‘/root/.ansible/plugins/modules‘, ‘/usr/share/ansible/plugins/modules‘] ansible python module location = /usr/lib/python3.6/site-packages/ansible executable location = /usr/bin/ansible python version = 3.6.8 (default, Nov 21 2019, 19:31:34) [GCC 8.3.1 20190507 (Red Hat 8.3.1-4)] 通过使用setup模块验证localhost上的ansible_python_version [root@localhost ~]# ansible -m setup localhost|grep ansible_python_version "ansible_python_version": "3.6.8",
标签:comm nsa ack 配置文件 erp Opens paramiko summary playbook
原文地址:https://www.cnblogs.com/meijianbiao/p/14237626.html