有什么方法可以回滚 Ansible 中的更改吗?假设我的剧本包含不同的剧本,例如创建 5 个用户、安装 3 rpm、启动服务。如果我想回滚某个游戏,我该怎么做。我们是否有可能在 anisble 中实现这一目标?
我想将以前与 Ansible(独立)一起使用的现有清单包括 group_vars 和保险库文件导入 Ansible Tower (3.2.0)。
但是,一旦 Vault 文件发挥作用,它似乎就不起作用了。一旦我设置了 Vault 密码文件凭据并使用源类型“源自项目”创建清单 - 我无法在“源详细信息”下选择 Vault 凭据。
当我手动将其放入并保存源时 - 同步失败并出现以下错误:
1.735 INFO Updating inventory 10: TEST
1.753 DEBUG Using system install of ansible-inventory CLI: /usr/bin/ansible-inventory
1.753 INFO Reading Ansible inventory source: /var/lib/awx/projects/_6__ansible_master/inventories/test/hosts
1.754 DEBUG Using private credential data in '/tmp/awx_123_LXUj9p'.
1.755 DEBUG Using fresh temporary directory '/tmp/awx_proot_ZURWmR' for isolation.
1.755 DEBUG Running from `/var/lib/awx/projects/_6__ansible_master/inventories/test` working directory.
Traceback (most recent call last):
File "/usr/bin/awx-manage", line 9, in <module>
load_entry_point('awx==3.2.0', 'console_scripts', 'awx-manage')()
File …
Run Code Online (Sandbox Code Playgroud) 我从 powershell 命令获取计数并将其注册到变量上。我必须在 when 条件下使用该计数。在 when 条件下使用它之前,我已将其更改为 int 。尽管此处的计数为 0,但仍会跳过该任务(邮件通知)。有人可以告诉我我在这里做错了什么。下面是我正在执行的代码
- name: Get message_count
shell: echo "{{ (output.stdout | from_json).MessageCount }}"
register: message_count #message_count is Zero here
delegate_to: localhost
- set_fact:
countt: "{{ message_count | int}}"
Run Code Online (Sandbox Code Playgroud)
#在使用 set_fact 传递给条件之前尝试转换为整数
- debug: var=countt
- name: send mail notification
mail:
host: abc.zzzz.net
port: 25
from: <noreply@controlnode.com>
to:
- abc@xyz.com
subject: Test mail sent from core server
body: Test mail sent from core server
delegate_to: localhost
when: countt==0
Run Code Online (Sandbox Code Playgroud) 我在 ansible 中创建了大约 30 个角色。我是否必须手动转换单个剧本中的那些内容才能在 Ansible Tower 中使用它们?