mirror of
https://github.com/freeipa/ansible-freeipa.git
synced 2026-07-31 11:54:47 +00:00
utils/build-galaxy-release.sh: New build script for galaxy release
This script will to the following steps: - Fix the galaxy release in galaxy.yml - Remove emacs backup files - Link module_utils, modules and action_plugins from roles to plugins/.. - Fix import prefix for module_utils - Fix module prefixes in playbooks and example playbooks - Build release using mazer - Clean up again
This commit is contained in:
46
utils/build-galaxy-release.sh
Normal file
46
utils/build-galaxy-release.sh
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
galaxy_version=$(git describe --tags | sed -e "s/^v//")
|
||||||
|
echo $galaxy_version | grep "-" -q || galaxy_version="${galaxy_version}-1"
|
||||||
|
sed -i -e "s/version: .*/version: \"$galaxy_version\"/" galaxy.yml
|
||||||
|
|
||||||
|
find . -name "*~" -exec rm {} \;
|
||||||
|
|
||||||
|
sed -i -e "s/ansible.module_utils.ansible_freeipa_module/ansible_collections.freeipa.ansible_freeipa.plugins.module_utils.ansible_freeipa_module/" *.py
|
||||||
|
|
||||||
|
cd plugins/module_utils && {
|
||||||
|
ln -s ../../roles/ipa*/module_utils/*.py .
|
||||||
|
cd ../..
|
||||||
|
}
|
||||||
|
|
||||||
|
cd plugins/modules && {
|
||||||
|
sed -i -e "s/ansible.module_utils.ansible_ipa_/ansible_collections.freeipa.ansible_freeipa.plugins.module_utils.ansible_ipa_/" ../../roles/ipa*/library/*.py
|
||||||
|
ln -s ../../roles/ipa*/library/*.py .
|
||||||
|
cd ../..
|
||||||
|
}
|
||||||
|
|
||||||
|
[ ! -x plugins/action_plugins ] && mkdir plugins/action_plugins
|
||||||
|
cd plugins/action_plugins && {
|
||||||
|
ln -s ../../roles/ipa*/action_plugins/*.py .
|
||||||
|
cd ../..
|
||||||
|
}
|
||||||
|
|
||||||
|
for x in roles/ipa*/tasks/*.yml; do
|
||||||
|
python utils/galaxyify-playbook.py "$x"
|
||||||
|
done
|
||||||
|
|
||||||
|
for x in $(find playbooks -name "*.yml" -print); do
|
||||||
|
python utils/galaxyify-playbook.py "$x"
|
||||||
|
done
|
||||||
|
|
||||||
|
#git diff
|
||||||
|
|
||||||
|
mazer build
|
||||||
|
|
||||||
|
rm plugins/module_utils/ansible_ipa_*
|
||||||
|
rm plugins/modules/ipaserver_*
|
||||||
|
rm plugins/modules/ipareplica_*
|
||||||
|
rm plugins/modules/ipaclient_*
|
||||||
|
rm plugins/action_plugins/ipaclient_*
|
||||||
|
git reset --hard
|
||||||
|
|
||||||
39
utils/galaxyify-playbook.py
Normal file
39
utils/galaxyify-playbook.py
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import re
|
||||||
|
|
||||||
|
def galaxify_playbook(playbook_in):
|
||||||
|
p1 = re.compile('(ipa.*:)$')
|
||||||
|
p2 = re.compile('(name:) (ipa.*)$')
|
||||||
|
lines = [ ]
|
||||||
|
|
||||||
|
with open(playbook_in) as in_f:
|
||||||
|
changed = False
|
||||||
|
changeable = False
|
||||||
|
include_role = False
|
||||||
|
for line in in_f:
|
||||||
|
stripped = line.strip()
|
||||||
|
if stripped.startswith("- name:") or \
|
||||||
|
stripped.startswith("- block:"):
|
||||||
|
changeable = True
|
||||||
|
elif stripped in [ "set_fact:", "vars:" ]:
|
||||||
|
changeable = False
|
||||||
|
include_role = False
|
||||||
|
elif stripped.startswith("include_role:"):
|
||||||
|
include_role = True
|
||||||
|
elif include_role and stripped.startswith("name:"):
|
||||||
|
line = p2.sub(r'\1 freeipa.ansible_freeipa.\2', line)
|
||||||
|
changed = True
|
||||||
|
elif changeable and \
|
||||||
|
not stripped.startswith("freeipa.ansible_freeipa."):
|
||||||
|
line = p1.sub(r'freeipa.ansible_freeipa.\1', line)
|
||||||
|
changed = True
|
||||||
|
|
||||||
|
lines.append(line)
|
||||||
|
|
||||||
|
if changed:
|
||||||
|
with open(playbook_in, "w") as out_f:
|
||||||
|
for line in lines:
|
||||||
|
out_f.write(line)
|
||||||
|
|
||||||
|
galaxify_playbook(sys.argv[1])
|
||||||
Reference in New Issue
Block a user