当前位置:网站首页>[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!
边栏推荐
- Solidity - 安全 - 重入攻击(Reentrancy)
- The definition of strain was originally from stretch_ Ratio started
- PC viewing WiFi password
- Here comes the nearest chance to Ali
- Voting vault: a new primitive for defi and Governance
- Force deduction exercise -- deleting repeated items in ordered sequence 1.0
- [deep learning] data segmentation
- 云服务器部署 Web 项目
- InputStream转InputStreamSource
- What indicators should safety service engineers pay attention to in emergency response?
猜你喜欢

Codeforces B. MEX and Array
![[road of system analyst] collection of wrong topics in Project Management Chapter](/img/8b/2908cd282f5e505efe5223b4c5ddbf.jpg)
[road of system analyst] collection of wrong topics in Project Management Chapter
![[secretly kill little partner pytorch20 days] - [day4] - [example of time series data modeling process]](/img/f3/e51cb80f838faba8dfd90596d6e57b.jpg)
[secretly kill little partner pytorch20 days] - [day4] - [example of time series data modeling process]

Cisco VXLAN配置
![[GPU] basic operation of GPU (I)](/img/ce/0ca8c63525038fea64c40aabd17fc6.jpg)
[GPU] basic operation of GPU (I)

声网,站在物联网的“土壤”里

Rotating box target detection mmrotate v0.3.1 getting started

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

OSPF - authentication and load balancing summary (including configuration commands)

How to automatically renew a token after it expires?
随机推荐
剑指 Offer 22. 链表中倒数第k个节点
After reading who moved my cheese
86. 分隔链表
uboot通过终端发送‘r‘字符读取ddr内存大小
You don't know how to deduce the location where HashSet stores elements?
Promise知识点拾遗
We strongly recommend more than a dozen necessary plug-ins for idea development
Leader: who can use redis expired monitoring to close orders and get out of here!
Tornado frame foundation
[Blue Bridge Road -- bug free code] analysis of AT24C02 storage code
Xijiao 21 autumn "motor and drive" online homework answer sheet (I) [standard answer]
旋转框目标检测mmrotate v0.3.1 学习配置
Learning about functions QAQ
Vfpbs uploads excel and saves MSSQL to the database
Idea of capturing mobile terminal variant combination
Sword finger offer 22 The penultimate node in the linked list
Do you know how to show the health code in only 2 steps
[Blue Bridge Road -- bug free code] DS1302 time module code analysis
InputStream to inputstreamsource
如何写论文