上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 21 下一页
摘要: 常常用于判断前一个命令执行的结果. | 参数 | 释义 | 示例 | | | | | | success | 执行状态为成功为真 | when: result is success | | succeeded | | | | failure | 执行状态为失败为真 | when: result is 阅读全文
posted @ 2023-01-24 12:34 mingtian是吧 阅读(14) 评论(0) 推荐(0) 编辑
摘要: | 参数 | 释义 | 示例 | | | | | | defined | 变量已定义 | when: username is defined | | undefind | 变量未定义 | when: username is undfined | | none | 变量已定义未赋值 | when: u 阅读全文
posted @ 2023-01-24 12:24 mingtian是吧 阅读(11) 评论(0) 推荐(0) 编辑
摘要: 判断添加用户 - hosts: all vars: - username: test1 tasks: - name: detect whether the user exists shell: id {{ username }} register: result ignore_errors: tru 阅读全文
posted @ 2023-01-22 10:56 mingtian是吧 阅读(10) 评论(0) 推荐(0) 编辑
摘要: | 逻辑运算 | 释义 | | | | | and | 逻辑与 | | or | 逻辑或 | | not | 逻辑取反 | 示例一: 等同于: if ansible_distribution == "CentOS" and ansible_distribution_major_version == 阅读全文
posted @ 2023-01-22 10:55 mingtian是吧 阅读(16) 评论(0) 推荐(0) 编辑
摘要: | 比较符 | 释义 | | | | | == | 等于 | | != | 不等 | | < | 小于 | | <= | 小于等于 | | > | 大于 | | >= | 大于等于 | 示例一: 需要注意 when 使用变量时不需要 {{}} - hosts: all tasks: - name: 阅读全文
posted @ 2023-01-22 10:54 mingtian是吧 阅读(20) 评论(0) 推荐(0) 编辑
摘要: package main import ( "fmt" "net/http" ) func main() { http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { fmt.Fprint(w, "Hello, World 阅读全文
posted @ 2023-01-20 16:06 mingtian是吧 阅读(236) 评论(0) 推荐(0) 编辑
摘要: 功能类似于: 列表元素数量上要一一对应 for i in zip([1,2,3],['a','b','c']): print(i) - hosts: all tasks: - name: debug debug: msg: "{{ item }}" with_together: - ["a","b" 阅读全文
posted @ 2023-01-20 10:39 mingtian是吧 阅读(12) 评论(0) 推荐(0) 编辑
摘要: 添加索引 - hosts: all tasks: - name: debug debug: msg: "{{ item }}" with_indexed_items: - [1,2,3] - ['a','b','c','d'] - hosts: all tasks: - name: debug de 阅读全文
posted @ 2023-01-20 10:28 mingtian是吧 阅读(12) 评论(0) 推荐(0) 编辑
摘要: 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: 阅读全文
posted @ 2023-01-20 09:38 mingtian是吧 阅读(79) 评论(0) 推荐(0) 编辑
摘要: - hosts: all tasks: - name: debug debug: msg: "{{ item.key }} 的名字叫 {{ item.value.name }}" with_dict: - user01: name: zhangsan age: 30 - user02: name: 阅读全文
posted @ 2023-01-20 09:31 mingtian是吧 阅读(16) 评论(0) 推荐(0) 编辑
上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 21 下一页