Created
September 29, 2019 13:33
-
-
Save WassimAkachi/80d09b21bf6cb2db99c75cae2439f83b to your computer and use it in GitHub Desktop.
Ansible init script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -euo pipefail | |
IFS=$'\n\t' | |
ANSIBLE_PROJECT_ROOT="." | |
if [[ $# -ge 1 ]] | |
then | |
ANSIBLE_PROJECT_ROOT="${1}" | |
fi | |
echo "ANSIBLE_PROJECT_ROOT='${ANSIBLE_PROJECT_ROOT}'" | |
folders=( | |
"inventories/production/group_vars" | |
"inventories/production/host_vars" | |
"inventories/staging/group_vars" | |
"inventories/staging/host_vars" | |
"library" | |
"module_utils" | |
"filter_plugins" | |
"roles" | |
) | |
files=( | |
"ansible.cfg" | |
"inventories/production/hosts" | |
"inventories/staging/hosts" | |
"inventories/production/group_vars/group1.yml" | |
"inventories/staging/group_vars/group1.yml" | |
"inventories/production/host_vars/hostname1.yml" | |
"inventories/staging/host_vars/hostname1.yml" | |
"site.yml" | |
"webservers.yml" | |
"dbservers.yml" | |
) | |
for folder in "${folders[@]}" | |
do | |
f="${ANSIBLE_PROJECT_ROOT}/${folder}" | |
mkdir -pv ${f} | |
done | |
for file in "${files[@]}" | |
do | |
f="${ANSIBLE_PROJECT_ROOT}/${file}" | |
[ -f ${f} ] || touch ${f} | |
done | |
cd ${ANSIBLE_PROJECT_ROOT} | |
tree --version >/dev/null 2>&1 && tree | |
git --version >/dev/null 2>&1 && [ ! -d .git ] && git init . |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment