【发布时间】:2020-11-26 18:14:32
【问题描述】:
我想在多台 linux 服务器上安装 Apache。 Apache 包在 RedHat 或 Debian 操作系统(apache2 vs httpd)上没有相同的名称:这是一种使用 ansible 事实变量(“ansible_os_family”)作为字典变量键的方法吗?
类似的东西(但这不起作用):
---
- name: playbook1
hosts: all
become: yes
vars:
apache_packages: {
"RedHat": "httpd",
"Debian": "apache2"
}
tasks:
- name: Install Apache server
package:
name: "{{ apache_packages['{{ ansible_os_family }}'] }}"
state: present
...
【问题讨论】:
标签: ansible ansible-facts