Blame SOURCES/vendoring-build.inc

a0bc34
# Unpack tar.gz to retrieve to be vendored modules and place them in the roles library.
a0bc34
# ansible.posix:
a0bc34
#   - library:
a0bc34
#     - Module selinux and seboolean for the selinux role
a0bc34
#     - Module mount for the storage role
a0bc34
declare -A module_map=( ["selinux.py"]="selinux" ["seboolean.py"]="selinux" ["mount.py"]="storage" )
a0bc34
for module in "${!module_map[@]}"; do
a0bc34
  role="${module_map[${module}]}"
a0bc34
  if [ ! -d $role/library ]; then
a0bc34
    mkdir $role/library
a0bc34
  fi
a0bc34
  cp -pL .external/ansible/posix/plugins/modules/$module $role/library/$module
a0bc34
  sed -i -e ':a;N;$!ba;s/description:\n\( *\)/description:\n\1- WARNING: Do not use this module directly! It is only for role internal use.\n\1/' -e "s/ansible_collections.ansible.posix.plugins.module_utils/ansible.module_utils.${role}_lsr/" $role/library/$module
a0bc34
done
a0bc34
a0bc34
# ansible.posix:
a0bc34
#   - module_utils:
a0bc34
#     - Module_util mount for the storage role
a0bc34
module_map=( ["mount.py"]="storage" )
a0bc34
for module in "${!module_map[@]}"; do
a0bc34
  role="${module_map[${module}]}"
a0bc34
  if [ ! -d $role/module_utils/${role}_lsr ]; then
a0bc34
    mkdir -p $role/module_utils/${role}_lsr
a0bc34
  fi
a0bc34
  cp -pL .external/ansible/posix/plugins/module_utils/$module $role/module_utils/${role}_lsr/$module
a0bc34
done
a0bc34
a0bc34
# community.general:
a0bc34
#   - library:
a0bc34
#     - Module seport, sefcontext and selogin for the selinux role rolename2
a0bc34
#     - Module ini_file for role tlog
a0bc34
#     - rhc modules
a0bc34
#     - ha_cluster uses modprobe
a0bc34
module_map=( ["seport.py"]="selinux" ["sefcontext.py"]="selinux" ["selogin.py"]="selinux" ["ini_file.py"]="tlog"
a0bc34
  ["redhat_subscription.py"]="rhc" ["rhsm_release.py"]="rhc" ["rhsm_repository.py"]="rhc"
a0bc34
  ["modprobe.py"]="ha_cluster" )
a0bc34
for module in "${!module_map[@]}"; do
a0bc34
  role="${module_map[${module}]}"
a0bc34
  if [ ! -d $role/library ]; then
a0bc34
    mkdir $role/library
a0bc34
  fi
a0bc34
  # version 5.x seems to be broken?
a0bc34
  moduledir=.external/community/general/plugins/modules
a0bc34
  if [ ! -f $moduledir/$module ]; then
a0bc34
    moduledir=.external/community/general/plugins/modules/system
a0bc34
  fi
a0bc34
  if [ ! -f $moduledir/$module ]; then
a0bc34
    moduledir=.external/community/general/plugins/modules/files
a0bc34
  fi
a0bc34
  cp -pL $moduledir/$module $role/library/$module
a0bc34
  ls -alrtF $role/library/$module
a0bc34
  sed -i -e ':a;N;$!ba;s/description:\n\( *\)/description:\n\1- WARNING: Do not use this module directly! It is only for role internal use.\n\1/' $role/library/$module
a0bc34
a0bc34
  # Remove doc_fragments
a0bc34
  sed -i '/^extends_documentation_fragment:/,/^[^ -]/{/^extends/d;/^[ -]/d}' $role/library/$module
a0bc34
done
a0bc34
a0bc34
# containers.podman:
a0bc34
#   - library:
a0bc34
#     - Module podman_container_info, podman_image and podman_play for the podman role
a0bc34
module_map=( ["podman_container_info.py"]="podman" ["podman_image.py"]="podman" ["podman_play.py"]="podman" )
a0bc34
for module in "${!module_map[@]}"; do
a0bc34
  role="${module_map[${module}]}"
a0bc34
  if [ ! -d $role/library ]; then
a0bc34
    mkdir $role/library
a0bc34
  fi
a0bc34
  moduledir=.external/containers/podman/plugins/modules
a0bc34
  cp -pL $moduledir/$module $role/library/$module
a0bc34
  ls -alrtF $role/library/$module
a0bc34
  sed -i -e ':a;N;$!ba;s/description:\n\( *\)/description:\n\1- WARNING: Do not use this module directly! It is only for role internal use.\n\1/' \
a0bc34
    -e "s/ansible_collections.containers.podman.plugins.module_utils.podman/ansible.module_utils.${role}_lsr/" \
a0bc34
    $role/library/$module
a0bc34
done
a0bc34
a0bc34
# containers.podman:
a0bc34
#   - module_utils:
a0bc34
#     - Module_util common for the podman role
a0bc34
module_map=( ["common.py"]="podman" )
a0bc34
for module in "${!module_map[@]}"; do
a0bc34
  role="${module_map[${module}]}"
a0bc34
  if [ ! -d $role/module_utils/${role}_lsr ]; then
a0bc34
    mkdir -p $role/module_utils/${role}_lsr
a0bc34
  fi
a0bc34
  cp -pL .external/containers/podman/plugins/module_utils/podman/$module $role/module_utils/${role}_lsr/$module
a0bc34
done
a0bc34
a0bc34
# remove the temporary .external directory after vendoring
a0bc34
rm -rf .external
a0bc34
a0bc34
# Replacing "linux-system-roles.rolename" with "rhel-system-roles.rolename" in each role
a0bc34
# Replacing "fedora.linux_system_roles." with "redhat.rhel_system_roles" in each role
a0bc34
# This is for the "roles calling other roles" case
a0bc34
# for podman, change the FQCN - using a non-FQCN module name doesn't seem to work,
a0bc34
# even for the legacy role format
a0bc34
# replace community.general for rhc
a0bc34
for rolename in %{rolenames}; do
a0bc34
    find $rolename -type f -exec \
a0bc34
         sed -e "s/linux-system-roles[.]${rolename}\\>/%{roleinstprefix}${rolename}/g" \
a0bc34
             -e "s/fedora[.]linux_system_roles[.]/%{collection_namespace}.%{collection_name}./g" \
a0bc34
             -e "s/containers[.]podman[.]/%{collection_namespace}.%{collection_name}./g" \
a0bc34
             -e "s/community[.]general[.]/%{collection_namespace}.%{collection_name}./g" \
a0bc34
             -i {} \;
a0bc34
done