当前位置:网站首页>[ansible series] fundamentals 02 module debug
[ansible series] fundamentals 02 module debug
2022-06-30 05:51:00 【Pie Daxing's good friend Dingdang cat】
List of articles
1. Official module commissioning
ansible There are detailed debugging methods in the documentation of the developer's Guide , May refer to
Portal
2. Custom module debugging
Premise : The custom module will not go until there is a problem debug Customize the contents of the module , That is, the program is stuck in the custom module
Debugging steps
step1 View error details
The main purpose of viewing error details is to see playbook Temporary files generated during operation
ansible-playbook -i inventory all.yml -vvv
# The default host information is in inventory in
# Default playbook be known as all.yml
Example 
# Temporary file path of the module during operation
/root/.ansible/tmp/ansible-tmp-1614847639.99-2480-188457856158931/AnsiballZ_dataformat.py
step2 Processing files in temporary directory
Set the environment variable ANSIBLE_KEEP_REMOTE_FILES=1
The role of this environment variable :Ansible The remote module file will be preserved , Instead of deleting a module after its execution
export ANSIBLE_KEEP_REMOTE_FILES=1
To the temporary directory of the execution host
cd /root/.ansible/tmp/ansible-tmp-1614847639.99-2480-188457856158931/
There will be a... In the directory structure AnsiballZ_dataformat.py file
To run the wrapper explode command , Convert a string to something you can use Python file
python AnsiballZ_dataformat.py explode
stay AnsiballZ_dataformat.py The same level directory will generate debug_dir Catalog 
debug_dir/ansible/modulesThere are corresponding modules in the directorypythonCode , In the illustrated example isping.pydebug_dir/argsThe file contains a JSON character string . The string is a dictionary , contain Ansible Module parameters and other variables passed to a module to change its behavior . Modify this file to change the parameters passed to the module .
step3 debug Handle
It can be modified by modules The file corresponding to the module in the directory , Then execute the following statement under the temporary directory
python AnsiballZ_dataformat.py execute
tips: The common operation is to use in the module script file pdb Conduct debug, Step by step, find out the problem , If you run the above statement again, you will enter pdb Hit the breakpoint
pdb Commissioning the transfer gate
Stay Hungry,Stay Foolish!
边栏推荐
- Detailed explanation of issues related to SSL certificate renewal
- Here comes the nearest chance to Ali
- UML tools
- Promise knowledge points
- At the age of 32, I fell into a middle-aged crisis and finally quit naked...
- Use the code cloud publicholiday project to determine whether a day is a working day
- [Blue Bridge Road -- bug free code] analysis of AT24C02 storage code
- Xi'an Jiaotong 21st autumn online expansion resources of online trade and marketing (II)
- You don't know how to deduce the location where HashSet stores elements?
- We strongly recommend more than a dozen necessary plug-ins for idea development
猜你喜欢

Projet Web de déploiement du serveur Cloud

Redistemplate common method summary

Solitidy - fallback 回退函数 - 2种触发执行方式

Finally someone can make the server so straightforward

86. separate linked list

Delete the repeating elements in the sorting list (simple questions)

Lantern Festival | maoqiu technology and everyone "guess riddles and have a good night"

UE4_ Editor UMG close window cannot destroy UMG immediately

旋转框目标检测mmrotate v0.3.1 训练DOTA数据集(二)

旋转框目标检测mmrotate v0.3.1入门
随机推荐
English grammar_ Adjective / adverb Level 3 - superlative
At the beginning of 2022, people who are ready to change jobs should pay attention to
At the age of 32, I fell into a middle-aged crisis and finally quit naked...
uboot通过终端发送‘r‘字符读取ddr内存大小
Is it safe to open an account and trade with a compass?
旋转框目标检测mmrotate v0.3.1 学习配置
Navigate back to fragmentpageradapter - & gt; Fragment is empty - navigating back to fragmentpageradapter - & gt; fragments are empty
After getting these performance test decomposition operations, your test path will be more smooth
Use of tornado template
Related applications of priority queue
Xijiao 21 autumn "motor and drive" online homework answer sheet (I) [standard answer]
强烈推荐十几款IDEA开发必备的插件
2022年,谁在推动音视频产业的新拐点?
The definition of strain was originally from stretch_ Ratio started
【板栗糖GIS】global mapper—如何把栅格的高程值赋予给点
D. Big Brush
1380. lucky numbers in matrices
Xctf attack and defense world crypto advanced area
Dynamic programming -- gliding wing of the strange thief Kidd
电脑查看WiFi使用密码