Merge pull request #243 from t-woerner/galaxy-fix

Galaxy fix
This commit is contained in:
Rafael Guterres Jeffman
2020-04-06 20:44:21 -03:00
committed by GitHub
13 changed files with 35 additions and 38 deletions

View File

@@ -18,6 +18,7 @@ license_file: "COPYING"
dependencies: dependencies:
tags: tags:
- "system"
- "identity" - "identity"
- "ipa" - "ipa"
- "freeipa" - "freeipa"

View File

@@ -96,9 +96,6 @@ options:
config_master_host_name: config_master_host_name:
description: The config master_host_name setting description: The config master_host_name setting
required: no required: no
ccache:
description: The local ccache
required: no
installer_ccache: installer_ccache:
description: The installer ccache setting description: The installer ccache setting
required: no required: no
@@ -172,7 +169,6 @@ def main():
# additional # additional
server=dict(required=True), server=dict(required=True),
config_master_host_name=dict(required=True), config_master_host_name=dict(required=True),
ccache=dict(required=True),
installer_ccache=dict(required=True), installer_ccache=dict(required=True),
_ca_enabled=dict(required=False, type='bool'), _ca_enabled=dict(required=False, type='bool'),
_kra_enabled=dict(required=False, type='bool'), _kra_enabled=dict(required=False, type='bool'),
@@ -232,8 +228,6 @@ def main():
# additional # additional
options.server = ansible_module.params.get('server') options.server = ansible_module.params.get('server')
master_host_name = ansible_module.params.get('config_master_host_name') master_host_name = ansible_module.params.get('config_master_host_name')
ccache = ansible_module.params.get('ccache')
# os.environ['KRB5CCNAME'] = ccache
os.environ['KRB5CCNAME'] = ansible_module.params.get('installer_ccache') os.environ['KRB5CCNAME'] = ansible_module.params.get('installer_ccache')
installer._ccache = ansible_module.params.get('installer_ccache') installer._ccache = ansible_module.params.get('installer_ccache')
ca_enabled = ansible_module.params.get('_ca_enabled') ca_enabled = ansible_module.params.get('_ca_enabled')
@@ -268,8 +262,6 @@ def main():
remote_api = gen_remote_api(master_host_name, paths.ETC_IPA) remote_api = gen_remote_api(master_host_name, paths.ETC_IPA)
installer._remote_api = remote_api installer._remote_api = remote_api
# ccache = os.environ['KRB5CCNAME']
with redirect_stdout(ansible_log): with redirect_stdout(ansible_log):
ansible_log.debug("-- INSTALL KRA --") ansible_log.debug("-- INSTALL KRA --")

View File

@@ -155,19 +155,19 @@ def main():
with redirect_stdout(ansible_log): with redirect_stdout(ansible_log):
argspec = inspect.getargspec(install_krb) argspec = inspect.getargspec(install_krb)
if "promote" in argspec.args: if "promote" in argspec.args:
krb = install_krb( install_krb(
config, config,
setup_pkinit=not options.no_pkinit, setup_pkinit=not options.no_pkinit,
pkcs12_info=pkinit_pkcs12_info, pkcs12_info=pkinit_pkcs12_info,
promote=promote) promote=promote)
else: else:
if "fstore" not in argspec.args: if "fstore" not in argspec.args:
krb = install_krb( install_krb(
config, config,
setup_pkinit=not options.no_pkinit, setup_pkinit=not options.no_pkinit,
pkcs12_info=pkinit_pkcs12_info) pkcs12_info=pkinit_pkcs12_info)
else: else:
krb = install_krb( install_krb(
config, config,
setup_pkinit=not options.no_pkinit, setup_pkinit=not options.no_pkinit,
pkcs12_info=pkinit_pkcs12_info, pkcs12_info=pkinit_pkcs12_info,

View File

@@ -606,7 +606,6 @@
server: "{{ result_ipareplica_test.server }}" server: "{{ result_ipareplica_test.server }}"
config_master_host_name: config_master_host_name:
"{{ result_ipareplica_prepare.config_master_host_name }}" "{{ result_ipareplica_prepare.config_master_host_name }}"
ccache: "{{ result_ipareplica_prepare.ccache }}"
installer_ccache: "{{ result_ipareplica_prepare.installer_ccache }}" installer_ccache: "{{ result_ipareplica_prepare.installer_ccache }}"
_ca_enabled: "{{ result_ipareplica_prepare._ca_enabled }}" _ca_enabled: "{{ result_ipareplica_prepare._ca_enabled }}"
_kra_enabled: "{{ result_ipareplica_prepare._kra_enabled }}" _kra_enabled: "{{ result_ipareplica_prepare._kra_enabled }}"

View File

@@ -58,7 +58,7 @@ options:
description: The starting value for the IDs range (default random) description: The starting value for the IDs range (default random)
required: no required: no
idmax: idmax:
description: The max value for the IDs range (default: idstart+199999) description: The max value for the IDs range (default idstart+199999)
required: no required: no
no_hbac_allow: no_hbac_allow:
description: Don't install allow_all HBAC rule description: Don't install allow_all HBAC rule

View File

@@ -79,7 +79,7 @@ options:
description: The starting value for the IDs range (default random) description: The starting value for the IDs range (default random)
required: no required: no
idmax: idmax:
description: The max value for the IDs range (default: idstart+199999) description: The max value for the IDs range (default idstart+199999)
required: no required: no
no_hbac_allow: no_hbac_allow:
description: Don't install allow_all HBAC rule description: Don't install allow_all HBAC rule

View File

@@ -55,7 +55,7 @@ options:
description: The starting value for the IDs range (default random) description: The starting value for the IDs range (default random)
required: no required: no
idmax: idmax:
description: The max value for the IDs range (default: idstart+199999) description: The max value for the IDs range (default idstart+199999)
required: no required: no
no_hbac_allow: no_hbac_allow:
description: Don't install allow_all HBAC rule description: Don't install allow_all HBAC rule

View File

@@ -111,7 +111,7 @@ options:
description: The starting value for the IDs range (default random) description: The starting value for the IDs range (default random)
required: no required: no
idmax: idmax:
description: The max value for the IDs range (default: idstart+199999) description: The max value for the IDs range (default idstart+199999)
required: no required: no
domainlevel: domainlevel:
description: The domain level description: The domain level

View File

@@ -98,7 +98,7 @@ options:
description: The starting value for the IDs range (default random) description: The starting value for the IDs range (default random)
required: no required: no
idmax: idmax:
description: The max value for the IDs range (default: idstart+199999) description: The max value for the IDs range (default idstart+199999)
required: no required: no
no_reverse: no_reverse:
description: Do not create new reverse DNS zone description: Do not create new reverse DNS zone

View File

@@ -79,7 +79,7 @@ options:
description: The starting value for the IDs range (default random) description: The starting value for the IDs range (default random)
required: yes required: yes
idmax: idmax:
description: The max value for the IDs range (default: idstart+199999) description: The max value for the IDs range (default idstart+199999)
required: yes required: yes
no_pkinit: no_pkinit:
description: Disable pkinit setup steps description: Disable pkinit setup steps

View File

@@ -1,36 +1,40 @@
#!/bin/bash #!/bin/bash
namespace="freeipa"
collection="ansible_freeipa"
collection_prefix="${namespace}.${collection}"
galaxy_version=$(git describe --tags | sed -e "s/^v//") galaxy_version=$(git describe --tags | sed -e "s/^v//")
echo $galaxy_version | grep "-" -q || galaxy_version="${galaxy_version}-1" echo $galaxy_version | grep "-" -q || galaxy_version="${galaxy_version}"
sed -i -e "s/version: .*/version: \"$galaxy_version\"/" galaxy.yml sed -i -e "s/version: .*/version: \"$galaxy_version\"/" galaxy.yml
find . -name "*~" -exec rm {} \; 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/" plugins/modules/*.py sed -i -e "s/ansible.module_utils.ansible_freeipa_module/ansible_collections.${collection_prefix}.plugins.module_utils.ansible_freeipa_module/" plugins/modules/*.py
cd plugins/module_utils && { cd plugins/module_utils && {
ln -s ../../roles/ipa*/module_utils/*.py . ln -s ../../roles/*/module_utils/*.py .
cd ../.. cd ../..
} }
cd plugins/modules && { 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 sed -i -e "s/ansible.module_utils.ansible_ipa_/ansible_collections.${collection_prefix}.plugins.module_utils.ansible_ipa_/" ../../roles/*/library/*.py
ln -s ../../roles/ipa*/library/*.py . ln -s ../../roles/*/library/*.py .
cd ../.. cd ../..
} }
[ ! -x plugins/action_plugins ] && mkdir plugins/action_plugins [ ! -x plugins/action_plugins ] && mkdir plugins/action_plugins
cd plugins/action_plugins && { cd plugins/action_plugins && {
ln -s ../../roles/ipa*/action_plugins/*.py . ln -s ../../roles/*/action_plugins/*.py .
cd ../.. cd ../..
} }
for x in roles/ipa*/tasks/*.yml; do for x in roles/*/tasks/*.yml; do
python utils/galaxyify-playbook.py "$x" python utils/galaxyfy-playbook.py "$x" "ipa" "$collection_prefix"
done done
for x in $(find playbooks -name "*.yml" -print); do for x in $(find playbooks -name "*.yml" -print); do
python utils/galaxyify-playbook.py "$x" python utils/galaxyfy-playbook.py "$x" "ipa" "$collection_prefix"
done done
#git diff #git diff
@@ -43,4 +47,3 @@ rm plugins/modules/ipareplica_*
rm plugins/modules/ipaclient_* rm plugins/modules/ipaclient_*
rm plugins/action_plugins/ipaclient_* rm plugins/action_plugins/ipaclient_*
git reset --hard git reset --hard

View File

@@ -2,11 +2,14 @@ import sys
import re import re
def galaxify_playbook(playbook_in): def galaxify_playbook(playbook_in, project_prefix, collection_prefix):
p1 = re.compile('(ipa.*:)$') p1 = re.compile('(%s.*:)$' % project_prefix)
p2 = re.compile('(.*:) (ipa.*)$') p2 = re.compile('(.*:) (%s.*)$' % project_prefix)
lines = [] lines = []
pattern1 = r'%s.\1' % collection_prefix
pattern2 = r'\1 %s.\2' % collection_prefix
with open(playbook_in) as in_f: with open(playbook_in) as in_f:
changed = False changed = False
changeable = False changeable = False
@@ -22,14 +25,13 @@ def galaxify_playbook(playbook_in):
elif stripped.startswith("include_role:"): elif stripped.startswith("include_role:"):
include_role = True include_role = True
elif include_role and stripped.startswith("name:"): elif include_role and stripped.startswith("name:"):
line = p2.sub(r'\1 freeipa.ansible_freeipa.\2', line) line = p2.sub(pattern2, line)
changed = True changed = True
elif changeable and stripped.startswith("- role:"): elif changeable and stripped.startswith("- role:"):
line = p2.sub(r'\1 freeipa.ansible_freeipa.\2', line) line = p2.sub(pattern2, line)
changed = True changed = True
elif changeable and not stripped.startswith( elif changeable and not stripped.startswith(collection_prefix):
"freeipa.ansible_freeipa."): line = p1.sub(pattern1, line)
line = p1.sub(r'freeipa.ansible_freeipa.\1', line)
changed = True changed = True
lines.append(line) lines.append(line)
@@ -40,4 +42,4 @@ def galaxify_playbook(playbook_in):
out_f.write(line) out_f.write(line)
galaxify_playbook(sys.argv[1]) galaxify_playbook(sys.argv[1], sys.argv[2], sys.argv[3])

View File

@@ -120,7 +120,7 @@ param_docs = {
"allow_zone_overlap": "Create DNS zone even if it already exists", "allow_zone_overlap": "Create DNS zone even if it already exists",
"skip_conncheck": "Skip connection check to remote master", "skip_conncheck": "Skip connection check to remote master",
"idstart": "The starting value for the IDs range (default random)", "idstart": "The starting value for the IDs range (default random)",
"idmax": "The max value for the IDs range (default: idstart+199999)", "idmax": "The max value for the IDs range (default idstart+199999)",
"no_hbac_allow": "Don't install allow_all HBAC rule", "no_hbac_allow": "Don't install allow_all HBAC rule",
"domainlevel": "The domain level", "domainlevel": "The domain level",
"external_ca_type": "Type of the external CA", "external_ca_type": "Type of the external CA",