-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support GET_PYTHON_MODULES - gather python module usage information
Run ansible with ANSIBLE_DEBUG=true and run each playbook with PYTHONVERBOSE=1 in order to trace python module execution, so that we can determine which python packages are required to run each role.
- Loading branch information
Showing
3 changed files
with
78 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--- | ||
- name: Get python modules from log file and create packages file | ||
hosts: all | ||
gather_facts: false | ||
vars: | ||
logfile: "" | ||
packages_file: packages.txt | ||
tasks: | ||
- name: Get list of modules | ||
set_fact: | ||
modules: "{{ lookup('file', logfile).splitlines() | select('match', __pat) | | ||
map('regex_replace', __pat, '\\1') | union(modules | d([])) | unique | list }}" | ||
vars: | ||
__pat: "^>>># /[^ ]+ matches (/[^ ]+?[.]py).*$" | ||
changed_when: false | ||
delegate_to: localhost | ||
|
||
- name: Copy modules file to host | ||
copy: | ||
content: "{{ modules | sort | join(__nl) ~ __nl }}" | ||
dest: /tmp/modules.txt | ||
mode: "0600" | ||
vars: | ||
__nl: "\n" | ||
|
||
- name: Get unique list of packages that provide modules in modules.txt | ||
shell: | | ||
declare -A packages | ||
while read -r file; do | ||
pkg="$(rpm -qf "$file" --queryformat '%{name}-%{version}-%{release}\n')" | ||
packages["$pkg"]="$pkg" | ||
done < /tmp/modules.txt | ||
for pkg in "${packages[@]}"; do | ||
echo "$pkg" | ||
done | sort > /tmp/packages.txt | ||
changed_when: false | ||
|
||
- name: Copy packages file back to localhost | ||
fetch: | ||
src: /tmp/packages.txt | ||
dest: "{{ packages_file }}" | ||
flat: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters