#!/bin/bash -eu # -*- coding: utf-8 -*- # Authors: # Thomas Woerner # # Copyright (C) 2020 Red Hat # see file 'COPYING' for use and warranty information # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . prog="$(basename "$0")" topdir="$(dirname "$0")" function usage() { cat < Create new ansible-freeipa module using templates. Options: -m Create module with member support -f Force creation -h Print this help EOF } member=0 force=0 while getopts "mfh" arg; do case $arg in m) member=1;; f) force=1;; h) usage; exit 0 ;; \?) echo "Invalid option: -$OPTARG" >&2 exit 1 ;; :) echo "Option -$OPTARG requires an argument." >&2 exit 1 ;; esac done for (( i=0; i "$d" } # MODULE dest=plugins/modules mkdir -p "$dest" src=ipamodule.py.in [ "$member" == "1" ] && src=ipamodule+member.py.in template "$src" "$dest/ipa$name.py" # README src=README-module.md.in [ "$member" == "1" ] && src=README-module+member.md.in template "$src" "README-$name.md" # PLAYBOOKS dest="playbooks/$name" mkdir -p "$dest" template module-present.yml.in "$dest/$name-present.yml" template module-absent.yml.in "$dest/$name-absent.yml" if [ "$member" == "1" ]; then template module-member-present.yml.in "$dest/$name-member-present.yml" template module-member-absent.yml.in "$dest/$name-member-absent.yml" fi # TESTS dest="tests/$name" mkdir -p "$dest" src=test_module.yml.in [ "$member" == "1" ] && src=test_module+member.yml.in template "$src" "$dest/test_$name.yml" template test_module_client_context.yml.in "$dest/test_${name}_client_context.yml"