我有一本叫做角色的游戏手册,用来为网站导入apache。问题是,当我查看ports.conf时,我只看到了website1的行。Website2从未被调用过。任何帮助都将不胜感激。
---
- hosts: all
vars_files:
- [ "./roles/apache-vhost/vars/website1.yml", "./roles/apache-vhost/vars/website12.yml"]
roles:
- apache-vhost/roles/apache-vhost/vars/website1.yml
site:
- domain: website1
http_port: 5000
https_port: 6000/角色/apache-vhost/vars/website2.yml
site:
- domain: website2
http_port: 5001
https_port: 6001游戏手册中的任务是
- name: add http Listeners to ports.conf
lineinfile:
path: /etc/httpd/conf.d/ports.conf
line: 'Listen {{item.http_port}} #{{ item.domain}}'
loop: "{{ site }}"
- name: add https Listeners to ports.conf
lineinfile:
path: /etc/httpd/conf.d/ports.conf
line: 'Listen {{item.https_port}} #{{ item.domain}}'
loop: "{{ site }}"谢谢。
发布于 2021-06-11 21:00:25
来自第二个文件website2.yml的可变站点重写了来自第一个文件website1.yml的值。
- hosts: localhost
vars_files:
- website1.yml
- website2.yml
tasks:
- debug:
var: site给出
site:
- domain: website2
http_port: 5001
https_port: 6001您将不得不在一个循环中连接(合并)列表。
- hosts: localhost
tasks:
- set_fact:
site: "{{ site|default([]) + x.site }}"
loop:
- website1.yml
- website2.yml
vars:
x: "{{ lookup('file', item)|from_yaml }}"
- debug:
var: site给出
site:
- domain: website1
http_port: 5000
https_port: 6000
- domain: website2
http_port: 5001
https_port: 6001https://serverfault.com/questions/1066467
复制相似问题