随笔分类 - CI/CD
摘要:1、安装依赖 yum install gem -y gem install builder yum install gem -y gem install builder 2、安装、配置nginx的文件列表 添加/etc/nginx/default.d/mirrors.conf文件如下内容 locat
阅读全文
摘要:在一个task中循环某个操作 1、标准循环 - name: add several users user: name: "{{ item }}" state: present groups: "wheel" loop: - testuser1 - testuser2 #如果已经在变量文件中,定义了y
阅读全文
摘要:ansible插件是增强ansible的核心功能的代码片段,ansible使用插件架构来实现丰富,灵活和可扩展的功能集。 Ansible提供了许多方便的插件,您可以轻松编写自己的插件。 下边简单介绍Ansible包含的各种插件(插件具体用法请参考官方文档或者ansible-doc): 1、actio
阅读全文
摘要:#理解 changed_when failed_when become become_user ansible_become ansible_become_user static #检查group_vars中某组是否存在主机 - name: ensure only one monitoring host exists fail: msg="One, or no monitoring ho...
阅读全文
摘要:facts Facts通过访问远程系统获取相应的信息。 一个例子就是远程主机的IP地址或者操作系统是什么. 使用以下命令可以查看哪些信息是可用的: 这会返回巨量的变量数据,比如对于Ubutu 12.04系统,Ansible 1.4获取的信息显示如下: 引用返回的fact变量: 在模板和条件判断中会经
阅读全文
摘要:1、加速模式运行playbook 对于使用ansible 1.5 及之后版本的用户,加速模式只在以下情况下有用处: (A) 管理红帽企业版 Linux 6 或者更早的那些依然使用 paramiko 的版本 (B) 像在文档中描述的那样:无法在 TTYs 中使用 sudo. 2、异步操作和轮询 默认情
阅读全文
摘要:一、Jinja2介绍 Jinja2是基于python的模板引擎,功能比较类似于PHP的smarty,J2ee的Freemarker和velocity。它能完全支持unicode,并具有集成的沙箱执行环境,应用广泛。jinja2使用BSD授权 Jinja2的语法是由variables(变量)和stat
阅读全文
摘要:我们使用查看ansible modules 和plugins 都可通过ansible-doc 命令在终端实现。 具体到ansible role,我们可以使用ansible-galaxy 在终端 search&install roles 也可以在ansible galaxy官网查询roles 命令行工
阅读全文
摘要:1、inventory文件 1、inventory文件说明: 目标主机的组织编排,灵活的将ad-hoc或plays传递给不同的主机。 主机、plays较少,直接在ansible 根目录使用hosts文件即可, 如果较为复杂,可以创建inventory文件夹,分不同inventory文件: inven
阅读全文
摘要:[action plugins] [cache plugins]jsonfilememcachedmemorymongodbpickleredisyaml [callback plugins]actionablecontext_demodebugdefaultdenseforemanfull_ski
阅读全文
摘要:##Some common modules[cloud modules] [clustering modules] [command modules]command - executes a command on a remote nodeexpect - executes a command an
阅读全文
摘要:# 检查主机连接 # ansible test -m ping # 执行远程命令 # ansible test -m command -a 'uptime' # 执行主控端脚本 # ansible test -m script -a '/etc/ansible/script/test.sh' # 执行远程主机的脚本 # ansible test -m shell -a 'ps aux|grep ...
阅读全文

浙公网安备 33010602011771号