首页 > 解决方案 > Ansible 循环查找问题

问题描述

我正在尝试从源代码安装 apache http 并使用以下编译命令,这会导致提到的错误。请问有什么帮助吗?

   - name: Install Apache, Version n -- {{ apache_version }})
     command: "{{ item }} chdir={{ apache_source_dir }}"
     with_items:
        - >
          ./configure --with-apr={{ apr-dir }} --with-apr-util={{ apr_util_dir }}
          --enable-mods-shared=all --enable-ssl --enable-so
          --with-pcre={{ pcre_dir}}/pcre-config --prefix={{ apache_install_dir }}`
        - /usr/bin/make
        - /usr/bin/make install
     become: yes

错误:

TASK [Install Apache, Version n -- 2.4.43)] ***************************************************
fatal: [physoaapp03-tst]: FAILED! => {"msg": "Unable to look up a name or access an attribute in template string (./configure --with-apr={{ apr-dir }} --with-apr-util={{ apr_util_dir }}  --enable-mods-shared=all --enable-ssl --enable-so  --with-pcre={{ pcre_dir}}/pcre-config --prefix={{ apache_install_dir }}`\n).\nMake sure your variable name does not contain invalid characters like '-': unsupported operand type(s) for -: 'StrictUndefined' and 'StrictUndefined'"}

谁能让我知道我需要在哪里改进代码?谢谢

标签: variablesansiblelookup

解决方案


确保您的变量名称不包含无效字符,如“-”

该错误已经描述了该问题以及如何解决它。

改成等等{{ apr-dir }}{{ apr_dir }}也更改声明。

请仔细阅读有关 ansible 中变量名称的文档,以避免将来出现此类问题。


推荐阅读