我需要在我的Linux系统上安装Symantec Endpoint Security,并尝试编写一个剧本来执行此操作
当我想安装程序时,我使用 ./install.sh -i 但是安装后,当我再次运行安装时,我得到以下消息:
root@TestKubuntu:/usr/SEP# ./install.sh -i
Starting to install Symantec Endpoint Protection for Linux
Downgrade is not supported. Please make sure the target version is newer than the original one.
这就是我在剧本中安装它的方式
- name: Install_SEP
command: bash /usr/SEP/install.sh -i
我希望是否可以检查服务是否已启动,如果没有服务,请安装它,或者可能有更好的方法。
非常感谢您的时间
问:"我想检查服务是否已启动,如果没有服务,请安装它。
可以使用service_facts。例如,检查服务是否正在运行
vars:
my_service: "<name-of-my-service>"
tasks:
- name: Collect service facts
service_facts:
- name: Install service when not running
command: "<install-service>"
when: "my_service not in ansible_facts.services|
dict2items|
json_query('[?value.state == `running`].key')"
检查已安装的服务使用情况
json_query('[].key') }}"
(未测试(
请尝试以下操作。
- name: Check if service is up
command: <command to check if service is up>
register: output
- name: Install_SEP
command: bash /usr/SEP/install.sh -i
when: "'running' not in output.stdout"
注意:我使用了在 when 条件下运行:如果服务命令返回特定内容,请包含该命令而不是运行。