我已将所有剧本组织成角色。现在我已经拥有了所有角色,我正在尝试创建一个包含所有其他角色的新角色。
在 Ansible 中,是否可以创建一个只调用其他角色的角色?如果是这样,是否可以将其作为列表来执行,就像在剧本中一样:
---
- hosts: webservers
roles:
- role1
- role2
- role3
Run Code Online (Sandbox Code Playgroud) 我一直在压缩 IPv6 地址,但由于某种原因我无法压缩这个地址:
\n2\xe2\x80\x8bb\xe2\x80\x8b0\xe2\x80\x8b6\xe2\x80\x8b:\xe2\x80\x8b0\xe2\x80\x8b0\xe2\x80\x8b0\xe2\x80\x8b0\xe2\x80\x8b:\xe2\x80\x8b0\xe2\x80\x8b0\xe2\x80\x8b0\xe2\x80\x8b0\xe2\x80\x8b:\xe2\x80\x8b1\xe2\x80\x8bf\xe2\x80\x8b2\xe2\x80\x8bb\xe2\x80\x8b:\xe2\x80\x8bd\xe2\x80\x8b7\xe2\x80\x8b7\xe2\x80\x8bf\xe2\x80\x8b:\xe2\x80\x8b0\xe2\x80\x8b0\xe2\x80\x8b0\xe2\x80\x8b0\xe2\x80\x8b:\xe2\x80\x8b0\xe2\x80\x8b0\xe2\x80\x8b0\xe2\x80\x8b0\xe2\x80\x8b:\xe2\x80\x8b8\xe2\x80\x8b9\xe2\x80\x8bc\xe2\x80\x8be\xe2\x80\x8b
这也是我压缩的:2b06::1f2b:d77f::89ce
但这不起作用,我想知道为什么。
\n我只想从 yaml 文件 download.yaml 下载文件(仅当它们发生更改时)。
我已经找到了这个/sf/answers/1586792441/但似乎 ansible 仍然下载整个文件,即使它没有改变
playbook.yaml 中的任务:
tasks:
- name: Download File
get_url:
url="{{ item.value.url }}"
dest="{{ item.value.dest }}{{item.value.file }}"
loop: "{{ lookup('dict', dl) }}"
Run Code Online (Sandbox Code Playgroud)
下载.yaml:
dl:
4mlinux:
dest: /var/www/html/live/asset-mirror/releases/download/36.1-39ff9a19/
file: vmlinuz
url: https://github.com/netbootxyz/asset-mirror/releases/download/36.1-39ff9a19/vmlinuz
4mlinux-antivirus:
dest: /var/www/html/live/asset-mirror/releases/download/37.0-0.103.2-ba9e3ece/
file: vmlinuz
url: https://github.com/netbootxyz/asset-mirror/releases/download/37.0-0.103.2-ba9e3ece/vmlinuz
4mlinux-bakandimg:
dest: /var/www/html/live/asset-mirror/releases/download/36.0-262576bf/
file: vmlinuz
url: https://github.com/netbootxyz/asset-mirror/releases/download/36.0-262576bf/vmlinuz
Run Code Online (Sandbox Code Playgroud)
编辑:
为了让我的问题更清楚。
Github 不提供版本的哈希值,请参阅此处Where to get MD5 hashes from a GitHub release?
我想避免自己计算校验和,因为校验和download.yaml是从另一个 yaml 文件生成的。
get_url如果模块仅检查文件的大小就足够了。
Edit2:
Ansible 仍然下载整个文件。以下是详细输出示例:
ok: [127.0.0.1] => (item={'key': …Run Code Online (Sandbox Code Playgroud) 我试图htop使用以下命令在 debian 服务器上安装:
ansible debian -m apt -a "name=htop state=present"
但我收到此错误:
ubuntu-20.lab | FAILED! => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python3"
},
"changed": false,
"msg": "'/usr/bin/apt-mark manual htop' failed: E: Could not create temporary file for /var/lib/apt/extended_states - mkstemp (13: Permission denied)\nE: Failed to write temporary StateFile /var/lib/apt/extended_states\n",
"rc": 100,
"stderr": "E: Could not create temporary file for /var/lib/apt/extended_states - mkstemp (13: Permission denied)\nE: Failed to write temporary StateFile /var/lib/apt/extended_states\n",
"stderr_lines": [
"E: Could not create temporary file for …Run Code Online (Sandbox Code Playgroud)