variables - 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'"}
谁能让我知道我需要在哪里改进代码?谢谢
解决方案
确保您的变量名称不包含无效字符,如“-”
该错误已经描述了该问题以及如何解决它。
改成等等{{ apr-dir }}
。{{ apr_dir }}
也更改声明。
请仔细阅读有关 ansible 中变量名称的文档,以避免将来出现此类问题。
推荐阅读
- firefox - 有没有办法在 Web 控制台(开发工具)上垂直编写?
- javascript - 使用 EJS 在列表中显示数组
- java - SQL 连接悬空:我在哪里没有正确关闭连接?
- logging - Elixir / Phoenix:如何自定义 HTTP 请求日志格式?
- python - Plotly 静态图像导出获取 OSError:[WinError 193] %1 不是有效的 Win32 应用程序
- excel - 包含变量的复杂公式中的引号
- sql - 如何计算查询时间的累积总和?
- excel - 更改 Power Query 数据源
- unit-testing - 为什么 Angular 8 单元测试中的 viewChild 参考未定义
- java - 如果由 ProcessBuilder() 执行,脚本看不到 ROS