我有一个运行自定义任务来设置 nginx 虚拟主机的剧本:
tasks:
- include: tasks/tweaks.yml
在本剧本中,var_files
使用了以下内容:
vars_files:
- ../config.yml
在config.yml
我有以下包含虚拟主机信息的列表:
nginx_hosts_custom:
- server_name: "mytest.dev"
root: /drupal/www/mytest
is_php: true
common_config: true
remote_host: "12.34.56.78"
remote_root: "/web/ubuntu/www/mytest/public"
pem: "mytest.pem"
在tweaks.yml
我有以下内容:
- name: "Extra Nginx hosts for the Drupal sites"
template:
src: ../templates/nginx-vhost.conf.j2
dest: "{{ nginx_vhost_path }}/{{ item.server_name.split(' ')[0] }}.conf"
force: yes
owner: root
group: root
mode: 0644
with_items: nginx_hosts_custom
notify: restart nginx
when: drupalvm_webserver == 'nginx'
这曾经完美地工作,但现在我在运行配置时收到以下错误:
fatal: [owenvm]: FAILED! => {"failed": true, "msg": "the field 'args' has an invalid value, which appears to include a variable that is undefined. The error was: 'unicode object' has no attribute 'server_name'\n\nThe error appears to have been in /tasks/tweaks.yml': line 20, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: \"Extra Nginx hosts for the Drupal sites\"\n ^ here\n"}
所以看起来变量server_name
没有被拾取 - 任何人都可以建议修复吗?