我已经编写了一个ansibe playbook来检查是否安装了oswatcher。如果没有,请安装它。
用于检查软件安装的shell脚本
#!/bin/bash
#Validation check that checks if oswatcher is installed
oswatcher=$(rpm -qa | grep "^oswatcher*" || echo "not_installed")
echo "$oswatcher"
此播放此处检查shell脚本输出并验证是否必须运行安装播放
- name: Execute script to check if oswatcher is installed
script: "{{ oswatch_home }}/version_details.sh"
register: oswatcher
- name: Print the Output
debug:
msg: "You can think the Application is installed, it is {{ oswatcher.stdout }}"
- include: oswatch-install.yml
when: oswatcher.stdout == "not_installed"
请参阅输出
PLAY [integration] *******************************************************************************************************************
TASK [Gathering Facts] ***************************************************************************************************************
ok: [xxxxxx]
ok: [xxxxxx]
TASK [app/oswatch : Execute script to check if oswatcher is installed] ***************************************************************
changed: [xxxxx1]
changed: [xxxxx2]
TASK [app/oswatch : Print the Output] ************************************************************************************************
ok: [xxxxxx1] => {
"changed": false,
"msg": "You can think the Application is installed, it is oswatcher-7.3.3-2.el6.noarch\r\n"
}
ok: [xxxxxx2] => {
"changed": false,
"msg": "You can think the Application is installed, it is not_installed\r\n"
}
TASK [app/oswatch : create project directory "/tmp/oswatch"] *************************************************************************
skipping: [xxxxxx1]
skipping: [xxxxxx2]
我的逻辑匹配not_installed并验证是否运行安装播放,它甚至打印它完全无法理解打嗝。
答案 0 :(得分:0)
将任务更改为以下内容并查看它是否正在服务。如果它仍然无效,请使用-vvv运行您的剧本并发布完整输出。
- include: oswatch-install.yml
when: "not_installed" in oswatcher.stdout