gpt4 book ai didi

Ansible playbook 来检查操作系统

转载 作者:行者123 更新时间:2023-12-04 12:24:53 25 4
gpt4 key购买 nike

如果系统安装了 Oracle Linux,我如何检查已安装的操作系统并继续下载文件。

这就是我要做的

- hosts: all
become: true
gather_facts: true
tasks:
- name: Check if oracle linux is installed
shell: |
cat: /etc/system-release
register: os_name
ignore_errors: yes
- debug:
msg: "{{os_name.stdout}}"```

最佳答案

- hosts: all
become: yes
gather_facts: true
tasks:

- name: downloading file if Oracle Linux is there
get_url:
url: #url of the file to download
dest: #path where you want to store it eg. /etc/downloaded-file
mode: '0600' #permissions to be given to the file
when: ansible_facts['distribution'] == "OracleLinux"

您可能想阅读此引用资料。
1. variable discover from system: Facts
2. Downloads files from HTTP, HTTPS, or FTP to node

关于Ansible playbook 来检查操作系统,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60048600/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com