随笔分类 - 运维工具
摘要:操作系统: centos7 arrch64 麒麟v10 镜像源:salt3006 rpm包 端口要求: 端口 类型 描述 4505 事件发布者/订阅服务器端口(发布作业/事件) 长连接 4506 数据负载和工作节点执行结果返回 (file services/return data) 需要时连接 sa
阅读全文
摘要:FROM centos:7 RUN echo -e "[salt]\nname=salt\nbaseurl=https://archive.repo.saltproject.io/yum/redhat/7/x86_64/3000/\nenabled=1\ngpgcheck=0\n" >/etc/yu
阅读全文
摘要:添加用户 useradd -M -s /sbin/nologin saltapi passwd saltapi 新增配置文件 # cat /etc/salt/master.d/eauth.conf external_auth: pam: saltapi: # 用户 - .* # 该配置文件给予sal
阅读全文
摘要:迁移前环境: salt-master 部署在3台物理机,计划性下线 salt-minion 分布在物理节点和pod 中,并通过salt-master的ip连接到master 迁移要求: 新的salt-master指向域名【salt-master.xxx.dev.xxx.com.】 需要pod和物理节
阅读全文
摘要:快速开始 新到一家公司使用了salt,这打破了我一直使用ansible的习惯,硬着头皮快速开始吧 使用docker环境快速学习 master的Dockerfile FROM centos:7 RUN curl -fsSL https://repo.saltproject.io/py3/redhat/
阅读全文
摘要:示例1 可以理解为: for item in groups.ungrouped: print(item) - hosts: all tasks: - name: debug debug: msg: "{{ item }}" with_items: "{{ groups.ungrouped }}" -
阅读全文
摘要:block 可以将多个task任务组合在一起执行,支持when判断,支持类似python中的try 语句。 python 语法举例: try: print(1/0) except: print(2) finally: print(3) block 举例: rescue 字面意识救援 - hosts:
阅读全文
摘要:failed_when 相当于exit,可以理解为: for i in range(10): if i >5: exit else: print(i) - hosts: all tasks: - name: ansible_os_family debug: msg: "{{ ansible_os_f
阅读全文
摘要:| 参数 | 释义 | | | | | string | 判断字符串 | | upper | 判断全大写 | | lower | 判断全小写 | - hosts: all tasks: - name: test string vars: msg: ABC debug: msg: "{{ msg }}
阅读全文
摘要:特别注意:这些文件的判断是用于判断ansible 运维主机上的文件,而不是远程主机 | 参数 | 释义 | | | | | file | 等同bash 中[ -f filename ] | | directory | 等同bash 中[ -d filename ] | | link | 等同bash
阅读全文
摘要:常常用于判断前一个命令执行的结果. | 参数 | 释义 | 示例 | | | | | | success | 执行状态为成功为真 | when: result is success | | succeeded | | | | failure | 执行状态为失败为真 | when: result is
阅读全文
摘要:| 参数 | 释义 | 示例 | | | | | | defined | 变量已定义 | when: username is defined | | undefind | 变量未定义 | when: username is undfined | | none | 变量已定义未赋值 | when: u
阅读全文
摘要:判断添加用户 - hosts: all vars: - username: test1 tasks: - name: detect whether the user exists shell: id {{ username }} register: result ignore_errors: tru
阅读全文
摘要:| 逻辑运算 | 释义 | | | | | and | 逻辑与 | | or | 逻辑或 | | not | 逻辑取反 | 示例一: 等同于: if ansible_distribution == "CentOS" and ansible_distribution_major_version ==
阅读全文
摘要:| 比较符 | 释义 | | | | | == | 等于 | | != | 不等 | | < | 小于 | | <= | 小于等于 | | > | 大于 | | >= | 大于等于 | 示例一: 需要注意 when 使用变量时不需要 {{}} - hosts: all tasks: - name:
阅读全文
摘要:功能类似于: 列表元素数量上要一一对应 for i in zip([1,2,3],['a','b','c']): print(i) - hosts: all tasks: - name: debug debug: msg: "{{ item }}" with_together: - ["a","b"
阅读全文
摘要:添加索引 - hosts: all tasks: - name: debug debug: msg: "{{ item }}" with_indexed_items: - [1,2,3] - ['a','b','c','d'] - hosts: all tasks: - name: debug de
阅读全文
摘要:with_nested 和with_cartesian 实现的功能相同。嵌套循环可以理解为: nest 英文嵌套 cartesian 英文笛卡尔积 for i in [1,2,3]: for j in ['a','b','c','d']: print(i,j) - hosts: all tasks:
阅读全文
摘要:- hosts: all tasks: - name: debug debug: msg: "{{ item.key }} 的名字叫 {{ item.value.name }}" with_dict: - user01: name: zhangsan age: 30 - user02: name:
阅读全文
摘要:with_list 不展开循环嵌套的列表。功能类似于 for i in zip([1,2,3],['a','b','c']): print(i) - hosts: all tasks: - name: debug debug: msg: "{{ item }}" with_list - ["a","
阅读全文
浙公网安备 33010602011771号