Ansible该任务包括带有未定义变量的选项

如何解决Ansible该任务包括带有未定义变量的选项

我正在使用ansible部署网站。但是我得到这个错误:

fatal: [lxc-server]: FAILED! => {"failed": true,"msg": "The task includes an option with an undefined variable. The error was: [{u'authorized_keys': u'{{ delivery_authorized_keys }}',u'group': u'{{ magento_webserver_group }}',u'name': u'{{ magento_project_user }}'}]: {{ http_group_name }}: 'http_group_name' is undefined\n\nThe error appears to have been in '/home/jredor/projets/webstore/architecture/provisioning/provision.yml': line 32,column 7,but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n    - name: \"Prepare the delivery_users object\"\n      ^ here\n\nexception type: <class 'ansible.errors.AnsibleUndefinedVariable'>\nexception: [{u'authorized_keys': u'{{ delivery_authorized_keys }}',u'name': u'{{ magento_project_user }}'}]: {{ http_group_name }}: 'http_group_name' is undefined"}

我知道有一些未定义的东西,但是事实是,它是由其他人开发的,应该可以正常工作,而这个其他人已经不在了。这是Provision.yml:

---
# load variables for each servers
- hosts:
    - dbservers
    - cacheservers
    - searchservers
    - webservers
  vars:
    ansible_user: "root"
  tasks:
    - include: includes/include-vars.yml

# Prepare the delivery authorized keys
- hosts:
    - dbservers
    - cacheservers
    - searchservers
    - webservers
  connection: local

  vars:
    ansible_user: "root"
    tmp_delivery_users:
      - name:   "{{ magento_project_user }}"
        group:  "{{ magento_webserver_group }}"
        authorized_keys: "{{ delivery_authorized_keys }}"

  tasks:
    - name: "Prepare the list of the authorized keys for delivery - Extra Keys"
      set_fact: delivery_authorized_keys="{{ delivery_authorized_extra_keys }}"

    - name: "Prepare the delivery_users object"
      set_fact: delivery_users="{{ tmp_delivery_users }}"

# add hosts alias on Servers
- hosts:
    - dbservers
    - cacheservers
    - searchservers
    - webservers
  vars:
    ansible_user: "root"
  tasks:
    - include: includes/init-hosts.yml
      with_items: "{{ specific_hosts|default([]) }}"

# add magento hosts alias on WebServers
- hosts:
    - webservers
  vars:
    ansible_user: "root"
  tasks:
    - include: includes/init-hosts.yml
      with_items: "{{ magento_server_alias|default([]) }}"

# Generic behaviors on all servers
- hosts:
    - dbservers
    - cacheservers
    - searchservers
    - webservers
  vars:
    ansible_user: "root"
  roles:
    - role: ansible-basicserver

# Generic usage of the ansible roles - DB Server
- hosts: dbservers
  vars:
    ansible_user: "root"
  roles:
    - role: ansible-mysql-server

# Generic usage of the ansible roles - Cache Server
- hosts: cacheservers
  vars:
    ansible_user: "root"
  roles:
    - {
        role: ansible-redis,redis_instance_name: "magento_cache",redis_setting_port:  "{{ magento_cache_port }}",redis_setting_save:  "{{ redis_setting_save_cache }}"
      }
    - {
        role: ansible-redis,redis_instance_name: "magento_session",redis_setting_port:  "{{ magento_cache_session_port }}",redis_setting_save:  "{{ redis_setting_save_session }}"
      }

# Generic usage of the ansible roles - Search Server
- hosts: searchservers
  vars:
    ansible_user: "root"
  roles:
    - role: ansible-elasticsearch

# Prepare php parameters
- hosts: webservers
  vars:
    ansible_user: "root"
  tasks:
    - include: includes/prepare-php-parameters.yml

# Generic usage of the ansible roles - Webserver Server
- hosts: webservers
  vars:
    ansible_user: "root"
  roles:
    - role: ansible-php
    - role: ansible-apache
    - role: ansible-varnish
    - role: ansible-nginx

# Specific usage of the ansible roles - Webserver Server - Dev Tools
- hosts: webservers
  vars:
    ansible_user: "root"
  roles:
    - { role: ansible-npm,when: magento_install_maildev or magento_install_grunt }
    - { role: ansible-maildev,when: magento_install_maildev }

  tasks:
  - name: "Install NPM package: grunt-cli"
    npm: name="grunt-cli" global=yes
    when: magento_install_grunt

  - name: "Add delivery user in groups"
    user:
      name: "{{ magento_project_user }}"
      groups: "{{ magento_delivery_groups }}"

  - name: "Create {{ magento_source_path }} folder"
    file:
      path:  "{{ magento_source_path }}"
      state: directory
      owner: "{{ magento_project_user }}"
      group: "{{ magento_project_group }}"
      mode:  "u=rwX,g=rX,o=rX"

# Specific task for Magento 2
  - name: "Check if Magento app/etc/env.php exists"
    stat:
      path: "{{ magento_source_path }}/app/etc/env.php"
    register: magento_app_etc_env

  - name: "Update app/etc/env.php configuration file"
    template:
      src: "templates/magento/env.php.j2"
      dest: "{{ magento_source_path }}/app/etc/env.php"
      owner: "{{ magento_project_user }}"
      group: "{{ magento_webserver_group }}"
      mode: "u=rw,g=rw,o=r"
    vars:
        magento_cache_database: "{{ magento_cache_database_for_run }}"
    when: magento_app_etc_env.stat.exists

# Update permissions
  - include: includes/permissions-tasks-full.yml

错误在那里触发:

  - name: "Prepare the delivery_users object"
  set_fact: delivery_users="{{ tmp_delivery_users }}"

所以,就像我说的那样,我知道http_group_name是未定义的,但是我该如何定义呢?我该如何调试?

我注意到在distro-vars中定义了http_group_name,其中每个distri都有一个yml文件。有CentOS-7,Debian-8,Debian-9,RadHat-7和Ubuntu-16.04。但是我的发行版是Ubuntu 20.04。可能是问题吗?我应该创建一个Ubuntu-20.04.yml吗? 谢谢

编辑: 我的env.php.j2

    {% set document_root_is_pub = 'false' %}
{% if magento_mode == 'production' %}{% set document_root_is_pub = 'true' %}{% endif %}
<?php
return array(
    'db' => array(
        'connection' => array(
            'default' => array(
                'host' => '{{ magento_db_host }}','dbname' => '{{ magento_db_name }}','username' => '{{ magento_db_user }}','password' => '{{ magento_db_password }}','model' => 'mysql4','engine' => 'innodb','initStatements' => 'SET NAMES utf8;','active' => '1','driver_options' => array(PDO::MYSQL_ATTR_LOCAL_INFILE => true),),'table_prefix' => '{{ magento_db_table_prefix }}','backend' => array(
        'frontName' => '{{ magento_backend_frontname }}','install' => array(
        'date' => '{{ magento_install_date }}','crypt' => array(
        'key' => '{{ magento_crypt_key }}','session' => array(
        'save' => 'redis','redis' => array(
            'host' => '{{ magento_cache_session_host }}','port' => '{{ magento_cache_session_port }}','database' => '{{ magento_cache_session_database }}','disable_locking' => '1','cache' => array(
        'frontend' => array(
            'default' => array(
                'backend' => 'Cm_Cache_Backend_Redis','id_prefix' => '{{ magento_cache_id_prefix }}','backend_options' => array(
                    'server' => '{{ magento_cache_host }}','port' => '{{ magento_cache_port }}','persistent' => '','database' => '{{ magento_cache_database }}','force_standalone' => '0','connect_retries' => '1','read_timeout' => '10','automatic_cleaning_factor' => '0','compress_data' => '1','compress_tags' => '1','compress_threshold' => '20480','compression_lib' => 'gzip','http_cache_hosts' => array(
{% set loop_index = 0 %}
{% for host in magento_http_cache_hosts %}
        {{ loop_index }} => array(
            'host' => '{{ host.host }}','port' => '{{ host.port }}',{% set loop_index = loop_index + 1 %}
{% endfor %}
    ),'MAGE_MODE' => '{{ magento_mode }}','directories' => array(
        'document_root_is_pub' => {{ document_root_is_pub }},'queue' => array(
        'amqp' => array(
            'host' => '','port' => '','user' => '','password' => '','virtualhost' => '/','ssl' => '','resource' => array(
        'default_setup' => array(
            'connection' => 'default','x-frame-options' => 'SAMEORIGIN','cache_types' => array(
        'config' => 1,'layout' => 1,'block_html' => 1,'collections' => 1,'reflection' => 1,'db_ddl' => 1,'eav' => 1,'customer_notification' => 1,'target_rule' => 1,'full_page' => 1,'config_integration' => 1,'config_integration_api' => 1,'translate' => 1,'config_webservice' => 1,);

我这里没有任何“ http_group_name”。这是错误吗?我应该在那里定义吗?如果是这样,我该怎么办?

解决方法

问题是发行版。自从我在容器上使用debian 10以来,我在debian 9上做了一个新的容器,它起作用了。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


依赖报错 idea导入项目后依赖报错,解决方案:https://blog.csdn.net/weixin_42420249/article/details/81191861 依赖版本报错:更换其他版本 无法下载依赖可参考:https://blog.csdn.net/weixin_42628809/a
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下 2021-12-03 13:33:33.927 ERROR 7228 [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPL
错误1:gradle项目控制台输出为乱码 # 解决方案:https://blog.csdn.net/weixin_43501566/article/details/112482302 # 在gradle-wrapper.properties 添加以下内容 org.gradle.jvmargs=-Df
错误还原:在查询的过程中,传入的workType为0时,该条件不起作用 &lt;select id=&quot;xxx&quot;&gt; SELECT di.id, di.name, di.work_type, di.updated... &lt;where&gt; &lt;if test=&qu
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct redisServer’没有名为‘server_cpulist’的成员 redisSetCpuAffinity(server.server_cpulist); ^ server.c: 在函数‘hasActiveC
解决方案1 1、改项目中.idea/workspace.xml配置文件,增加dynamic.classpath参数 2、搜索PropertiesComponent,添加如下 &lt;property name=&quot;dynamic.classpath&quot; value=&quot;tru
删除根组件app.vue中的默认代码后报错:Module Error (from ./node_modules/eslint-loader/index.js): 解决方案:关闭ESlint代码检测,在项目根目录创建vue.config.js,在文件中添加 module.exports = { lin
查看spark默认的python版本 [root@master day27]# pyspark /home/software/spark-2.3.4-bin-hadoop2.7/conf/spark-env.sh: line 2: /usr/local/hadoop/bin/hadoop: No s
使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams[&#39;font.sans-serif&#39;] = [&#39;SimHei&#39;] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -&gt; systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping(&quot;/hires&quot;) public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate&lt;String
使用vite构建项目报错 C:\Users\ychen\work&gt;npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-