当前位置:网站首页>[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
边栏推荐
猜你喜欢
随机推荐
rdma网络介绍
The getfield () method in TP5 changes, and TP5 gets the value of a single field
offset和client獲取dom元素比特置信息
Leetcode integer plus one
SQL学习|窗口函数
【MySQL基础篇】启动选项与配置文件
leetcode刷题之x的算术平方根
【Shell脚本练习】将新加的磁盘批量添加到指定的VG中
Usage of if conditional statements in SQL
基於DPDK實現VPC和IDC間互聯互通的高性能網關
JS性能优化
2021-09-18
JS regular matching first assertion and last assertion
微信小程序
Batch modify / batch update the value of a field in the database
Decentralized Collaborative Learning Framework for Next POI Recommendation
TP5中的getField()方法变化,tp5获取单个字段值
openvswitch 编译安装
JS performance optimization
TP6 的 each 遍历用法









