当前位置:网站首页>[fish in the net] ansible awx calls playbook to transfer parameters
[fish in the net] ansible awx calls playbook to transfer parameters
2022-04-23 06:58:00 【Sebastien23】
【 a fish escaped through the seine 】Ansible AWX call playbook The question of reference transmission
The problem background
adopt ansible AWX Use Web Interface call playbook when , There is playbook Some variables cannot be read at run time 、 And some variables read are different from the defined values .Playbook The structure is as follows :
my-test-playbook
|--ansible.cfg
|--fact_files
|--group_vars
|--all.yml
|--deploy.yml
|--inventory.ini
|--log
|--ansible.log
|--README
|--retry_files
|--roles
|--rolePremiere
|--defaults
|--main.yml
|--tasks
|--main.yml
|--files
|--templates
|--app.conf.j2
|--vars
|--roleSecond
|--roleThird
|--rollback.yml
|--start.yml
|--stop.yml
Question 1 : I can't read it inventory.ini The variables in the
stay inventory.ini
The following are defined in :
[appNode]
192.168.x.A ansible_ssh_port=xxx ansible_ssh_user=root
192.168.y.B ansible_ssh_port=xxx ansible_ssh_user=root
[all:vars]
major_version = 5
basedir = /opt/app
is_cluster = true
is_consistent = false
In execution roles/rolePremiere/tasks/main.yml
Related tasks in , In the use of inventory.ini in [all:vars]
When defining variables , Unexpectedly, it indicates that the variable is undefined ! however [appNode]
Medium hosts The information can be read .
Strangely enough , When I move these variables to group_vars/all.yml
Or corresponding role Under the defaults/main.yml
In the after , You can read the corresponding variables !
Question two : The read variable is different from the defined value
I am here roles/rolePremiere/templates/app.conf.j2
Variables are used in is_consistent
As a condition of judgment , as follows
{
% if ( is_consistent == "false" ) %}
According to the value defined above ( Suppose the variable is defined in group_vars/all.yml
in ), This judgment condition should hold . But in fact ,if The following corresponding statement does not execute .
By checking the logs and files on the target machine , When calling the template file , The value of this variable becomes False
, That is, the first letter becomes uppercase , Cause the judgment conditions to fail .
The way around is to rewrite the above judgment sentence as
{
% if ( is_consistent | string | lower == "false" ) %}
版权声明
本文为[Sebastien23]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230557416235.html
边栏推荐
猜你喜欢
随机推荐
Implementation of leetcode question brushing str ()
leetcode刷题之二进制求和
file_get_contents 访问 ssl 错误的两种解决方法
Working principle and practice of browser
【代码解析(2)】Communication-Efficient Learning of Deep Networks from Decentralized Data
ubuntu下搭建mysql环境 & 初识SQL
Oracle性能分析工具:OSWatcher
Web登录小案例(含验证码登录)
EF CORE在ASP.NET CORE项目中基于数据库优先模式生成实体模型
AttributeError: ‘dict‘ object has no attribute ‘iteritems‘
JS regular matching first assertion and last assertion
TP5中的getField()方法变化,tp5获取单个字段值
New formdata() when importing files
Solution to page cache problem (use with caution)
fdfs启动
阅读笔记:Secure Federated Matrix Factorization
LeetCode刷题|897递增顺序搜索树
Ansible基本命令、角色、内置变量与tests判断
时间格式不对,运行sql文件报错
【代码解析(6)】Communication-Efficient Learning of Deep Networks from Decentralized Data