首页 > 其他 > 详细

自动化运维工具 Ansible 安装、配置及使用

时间:2020-06-26 11:35:17      阅读:83      评论:0      收藏:0      [点我收藏+]

一、官方文档地址:https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html

 

二、ubuntu 20.04 安装 Ansible

$ sudo apt update
$ sudo apt install software-properties-common
$ sudo apt-add-repository --yes --update ppa:ansible/ansible
$ sudo apt install ansible

On older Ubuntu distributions, “software-properties-common” is called “python-software-properties”. 
You may want to use apt-get instead of apt in older versions. Also, be aware that only newer distributions
(i.e. 18.04, 18.10, etc.) have a -u or --update flag, so adjust your script accordingly.

按照官方文档的补充说明,在老版 ubuntu 中,需要将 software-properties-common 更改为 python-software-properties,根据本人以往安装该依赖的实际经验,
ubuntu16.04 以后的版本(不包括 ubuntu16.04)已更改为 software-properties-common

这里建议使用 pip 的方式进行安装:
  
  pip install ansible

  In order to use the paramiko connection plugin or modules that require paramiko, install the required module:

    
pip install paramiko
 

 

三、这里主要对使用 ansible-playbook 进行自动化运维的方式进行一下记录,如果有兴趣希望继续了解 ansible 的其他模块,可以去研读官方文档

1、ansible-playbook 的定义及作用:

About Playbooks
Playbooks are a completely different way to use ansible than in ad-hoc task execution mode, and are particularly powerful.

Simply put, playbooks are the basis for a really simple configuration management and multi-machine deployment system, unlike any that already exist, and one that is very well suited to deploying complex applications.

Playbooks can declare configurations, but they can also orchestrate steps of any manual ordered process, even as different steps must bounce back and forth between sets of machines in particular orders. They can launch tasks synchronously or asynchronously.

While you might run the main /usr/bin/ansible program for ad-hoc tasks, playbooks are more likely to be kept in source control and used to push out your configuration or assure the configurations of your remote systems are in spec.

There are also some full sets of playbooks illustrating a lot of these techniques in the ansible-examples repository. We’d recommend looking at these in another tab as you go along.

谷歌翻译如下:
  关于剧本

    与临时任务执行模式相比,剧本是使用ansible的完全不同的方式,并且功能特别强大。

    简而言之,剧本是真正简单的配置管理和多机部署系统的基础,这与现有的系统不同,并且非常适合于部署复杂的应用程序。

    剧本可以声明配置,但是它们也可以编排任何手动订购的过程的步骤,即使不同的步骤必须在特定顺序的机器之间来回跳动也是如此。他们可以同步或异步启动任务。

    尽管您可能会运行/usr/bin/ansible主程序来执行临时任务,但更可能将剧本保留在源代码管理中,并用于推送您的配置或确保远程系统的配置符合规范。

 

  

自动化运维工具 Ansible 安装、配置及使用

原文:https://www.cnblogs.com/lowmanisbusy/p/13194030.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!