@@ -27,21 +27,24 @@ jobs:
27
27
terraform_module_ansible : [ansible_sap_ecc_hana_system_copy_hdb,ansible_sap_hana_install,ansible_sap_s4hana_install_maintplan,ansible_sap_s4hana_system_copy_hdb]
28
28
steps :
29
29
- name : Checkout
30
- uses : actions/checkout@v2
30
+ uses : actions/checkout@v3.0.2
31
+ with :
32
+ path : gh_repo
31
33
- name : Ansible setup
32
34
id : local_setup
33
35
run : |
34
36
python --version
35
37
python -m pip install ansible-core requests beautifulsoup4 lxml
36
38
ansible --version
37
- ansible-galaxy collection install git+https://github.com/sap-linuxlab/community.sap_launchpad.git,main
39
+ ansible-galaxy collection install git+https://github.com/sap-linuxlab/community.sap_launchpad.git,main -p ./ansible_collections
38
40
- name : Terraform Module for Ansible - check software
39
41
id : identify_software_list
40
42
env :
41
43
sap_user_id : ${{ secrets.SAP_USER_ID }}
42
44
sap_user_id_password : ${{ secrets.SAP_USER_ID_PASSWORD }}
43
45
run : |
44
- cd "./all/${{ matrix.terraform_module_ansible }}"
46
+ export ANSIBLE_COLLECTIONS_PATH="$PWD/ansible_collections"
47
+ cd "./gh_repo/all/${{ matrix.terraform_module_ansible }}"
45
48
# Extract from softwarecenter_search_list_.* until first empty line, then remove yaml formatting and sort for unique
46
49
export software_list=$(cat create_ansible_extravars.tf | awk '!NF{f=0} /^.*softwarecenter_search_list.*/{f=1} f{print}' | awk '!/.*softwarecenter_search_list.*/' | awk '{sub(/#.*/,""); print}' | awk '{sub(/ .*- '\''/,""); print}' | tr -d "'" | sort | uniq)
47
50
export errors_list=""
@@ -57,13 +60,71 @@ jobs:
57
60
continue
58
61
fi
59
62
done
63
+ cd ../../../
60
64
if [ -z "$errors_list" ]
61
65
then
62
66
exit 0
63
67
else
64
- echo "### ERRORS indentified ####"
65
- echo "Terraform Templates for SAP require updating,"
68
+ echo "### ERRORS identified ####"
69
+ echo "Terraform Modules for SAP require updating,"
66
70
echo "as the following SAP Software are no longer available:"
67
71
echo "$errors_list" | tr " " "\n"
68
- exit 1
72
+ cd ./ansible_collections/community/sap_launchpad/plugins
73
+ touch python_module_fuzzy_call_script.py
74
+ echo '#!/usr/bin/env python3' >> python_module_fuzzy_call_script.py
75
+ echo 'import sys' >> python_module_fuzzy_call_script.py
76
+ echo 'search_file=sys.argv[1]' >> python_module_fuzzy_call_script.py
77
+ echo 'from module_utils.sap_launchpad_software_center_download_search_fuzzy import *' >> python_module_fuzzy_call_script.py
78
+ echo "username='$sap_user_id'" >> python_module_fuzzy_call_script.py
79
+ echo "password='$sap_user_id_password'" >> python_module_fuzzy_call_script.py
80
+ echo 'sap_sso_login(username, password)' >> python_module_fuzzy_call_script.py
81
+ echo 'query_result = search_software_fuzzy(search_file)' >> python_module_fuzzy_call_script.py
82
+ echo 'if len(query_result) >= 2:' >> python_module_fuzzy_call_script.py
83
+ echo " if 'IMDB_CLIENT20' in query_result[0]['Title']:" >> python_module_fuzzy_call_script.py
84
+ echo " print(query_result[-1]['Title'])" >> python_module_fuzzy_call_script.py
85
+ echo " elif '70SWPM' in query_result[0]['Title']:" >> python_module_fuzzy_call_script.py
86
+ echo " print(query_result[-1]['Title'])" >> python_module_fuzzy_call_script.py
87
+ echo " else:" >> python_module_fuzzy_call_script.py
88
+ echo ' for item in query_result:' >> python_module_fuzzy_call_script.py
89
+ echo ' print("ERROR. More than 1 result, manual intervention required.")' >> python_module_fuzzy_call_script.py
90
+ echo " print('Identified ' + item['Description'] + ', ' + item['Infotype'] + ': ' + item['Title'])" >> python_module_fuzzy_call_script.py
91
+ echo 'else:' >> python_module_fuzzy_call_script.py
92
+ echo " print(query_result[0]['Title'])" >> python_module_fuzzy_call_script.py
93
+ export exit1_check=0
94
+ cd ../../../../
95
+ for filename in $errors_list
96
+ do
97
+ filename_noext="${filename%.*}"
98
+ filename_id_only="${filename_noext##*-}"
99
+ cd ./ansible_collections/community/sap_launchpad/plugins
100
+ search_file=$(python ./python_module_fuzzy_call_script.py $filename_id_only)
101
+ cd ../../../../
102
+ if [[ "$search_file" == *"ERROR"* ]]; then
103
+ echo -e $search_file
104
+ printf $search_file
105
+ exit1_check=1
106
+ else
107
+ echo "Perform recursive sed for $filename change to $search_file"
108
+ cd "./gh_repo/all/${{ matrix.terraform_module_ansible }}"
109
+ find . -type f -not -path '*/\.*' -exec sed -i "s/$filename/$search_file/g" {} \;
110
+ cd ../../../
111
+ fi
112
+ done
113
+ if [[ "$exit1_check" -eq 1 ]]; then
114
+ exit 1
115
+ fi
116
+ fi
117
+ - name : Commit to main branch
118
+ id : git_commit_auto
119
+ run : |
120
+ cd ./gh_repo
121
+ if [[ $(git status --porcelain) ]]; then
122
+ git config user.name github-actions
123
+ git config user.email github-actions@github.com
124
+ git add .
125
+ git status
126
+ git commit -m "software-update: replace with new filenames $(date +%F_%H-%M)"
127
+ git push
128
+ else
129
+ exit 0
69
130
fi
0 commit comments