Skip to content

Instantly share code, notes, and snippets.

@simplygeekuk
Last active September 12, 2019 22:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simplygeekuk/cdf9d851524d91cf7ac27bfbfc6baffc to your computer and use it in GitHub Desktop.
Save simplygeekuk/cdf9d851524d91cf7ac27bfbfc6baffc to your computer and use it in GitHub Desktop.
#!/bin/sh
environments="production,staging,testing,development"
groups_vro="vro_appliances,vro_75_appliances,vro_76_appliances"
groups_vcsa="vcsa_appliances,vcsa_65_appliances,vcsa_67_appliances"
groups_nsxt="nsxt_appliances,nsxt_24_appliances,nsxt_25_appliances"
groups_vrlcm="vrlcm_appliances,vrlcm_21_appliances"
groups_vrli="vrli_appliances,vrli_48_appliances"
groups_vrops="vrops_appliances,vrops_75_appliances"
groups_vidm="vidm_appliances,vidm_33_appliances"
groups_vesxi="vesxi_hosts,vesxi_65_hosts,vesxi_67_hosts"
groups_pesxi="pesxi_hosts,pesxi_65_hosts,pesxi_67_hosts"
mkdir -p library module_utils filter_plugins roles
touch ansible.cfg ssh_config
cat <<EOF > ansible.cfg
[defaults]
inventory = inventory/development
roles_path = roles
library = library:/usr/share/ansible/plugins/modules
module_utils = module_utils
retry_files_enabled = False # Do not create them
retry_files_save_path = "/tmp/"
stdout_callback = yaml
bin_ansible_callbacks = True
#display_skipped_hosts = false
[ssh_connection]
ssh_args = -F ssh_config
EOF
cat <<EOF > ssh_config
host *
ForwardAgent yes
ForwardX11 no
ConnectionAttempts 3
ConnectTimeout 15
TCPKeepAlive yes
ServerAliveCountMax 6
ServerAliveInterval 30
ControlMaster auto
ControlPath /tmp/ssh-%r@%h:%pi
ControlPersist 60s
UserKnownHostsFile /dev/null
StrictHostKeyChecking no
EOF
for env in ${environments//,/ }; do
mkdir -p inventories/$env/{group_vars,host_vars}
mkdir -p inventories/$env/group_vars/all
touch inventories/$env/hosts
cat <<EOF > inventories/$env/hosts
all:
hosts:
localhost:
ansible_connection: local
children:
EOF
if [ ! -z "$groups_vro" ]; then
cat <<EOF >> inventories/$env/hosts
vro_appliances:
children:
vro_75_appliances:
hosts:
vro_76_appliances:
hosts:
EOF
for vro_group in ${groups_vro//,/ }; do
mkdir -p inventories/$env/group_vars/$vro_group
done
fi
if [ ! -z "$groups_vcsa" ]; then
cat <<EOF >> inventories/$env/hosts
vcsa_appliances:
children:
vcsa_65_appliances:
hosts:
vcsa_67_appliances:
hosts:
EOF
for vcsa_group in ${groups_vcsa//,/ }; do
mkdir -p inventories/$env/group_vars/$vcsa_group
done
fi
if [ ! -z "$groups_nsxt" ]; then
cat <<EOF >> inventories/$env/hosts
nsxt_appliances:
children:
nsxt_24_appliances:
hosts:
nsxt_25_appliances:
hosts:
EOF
for nsxt_group in ${groups_nsxt//,/ }; do
mkdir -p inventories/$env/group_vars/$nsxt_group
done
fi
if [ ! -z "$groups_vrlcm" ]; then
cat <<EOF >> inventories/$env/hosts
vrlcm_appliances:
children:
vrlcm_21_appliances:
hosts:
EOF
for vrlcm_group in ${groups_vrlcm//,/ }; do
mkdir -p inventories/$env/group_vars/$vrlcm_group
done
fi
if [ ! -z "$groups_vrli" ]; then
cat <<EOF >> inventories/$env/hosts
vrli_appliances:
children:
vrli_48_appliances:
hosts:
EOF
for vrli_group in ${groups_vrli//,/ }; do
mkdir -p inventories/$env/group_vars/$vrli_group
done
fi
if [ ! -z "$groups_vrops" ]; then
cat <<EOF >> inventories/$env/hosts
vrops_appliances:
children:
vrops_75_appliances:
hosts:
EOF
for vrops_group in ${groups_vrops//,/ }; do
mkdir -p inventories/$env/group_vars/$vrops_group
done
fi
if [ ! -z "$groups_vidm" ]; then
cat <<EOF >> inventories/$env/hosts
vidm_appliances:
children:
vidm_33_appliances:
hosts:
EOF
for vidm_group in ${groups_vidm//,/ }; do
mkdir -p inventories/$env/group_vars/$vidm_group
done
fi
if [ ! -z "$groups_vesxi" ]; then
cat <<EOF >> inventories/$env/hosts
vesxi_hosts:
children:
vesxi_65_hosts:
hosts:
vesxi_67_hosts:
hosts:
EOF
for vesxi_group in ${groups_vesxi//,/ }; do
mkdir -p inventories/$env/group_vars/$vesxi_group
done
fi
if [ ! -z "$groups_pesxi" ]; then
cat <<EOF >> inventories/$env/hosts
pesxi_hosts:
children:
pesxi_65_hosts:
hosts:
pesxi_67_hosts:
hosts:
EOF
for pesxi_group in ${groups_pesxi//,/ }; do
mkdir -p inventories/$env/group_vars/$pesxi_group
done
fi
done
if [ ! -z "$groups_vro" ]; then
touch vmware_deploy_vro.yml
cat <<EOF > vmware_deploy_vro.yml
---
- hosts: vro_appliances
become: no
gather_facts: False
roles:
- nmshadey.vmware_deploy_vro
EOF
fi
if [ ! -z "$groups_vcsa" ]; then
touch vmware_deploy_vcsa.yml
cat <<EOF > vmware_deploy_vcsa.yml
---
- hosts: vcsa_appliances
become: no
gather_facts: False
roles:
- nmshadey.vmware_deploy_vcsa
EOF
fi
if [ ! -z "$groups_nsxt" ]; then
touch vmware_deploy_nsxt.yml
cat <<EOF > vmware_deploy_nsxt.yml
---
- hosts: nsxt_appliances
become: no
gather_facts: False
roles:
- nmshadey.vmware_deploy_nsxt
EOF
fi
if [ ! -z "$groups_vrlcm" ]; then
touch vmware_deploy_vrlcm.yml
cat <<EOF > vmware_deploy_vrlcm.yml
---
- hosts: vrlcm_appliances
become: no
gather_facts: False
roles:
- nmshadey.vmware_deploy_vrlcm
EOF
fi
if [ ! -z "$groups_vrli" ]; then
touch vmware_deploy_vrli.yml
cat <<EOF > vmware_deploy_vrli.yml
---
- hosts: vrli_appliances
become: no
gather_facts: False
roles:
- nmshadey.vmware_deploy_vrli
EOF
fi
if [ ! -z "$groups_vrops" ]; then
touch vmware_deploy_vrops.yml
cat <<EOF > vmware_deploy_vrops.yml
---
- hosts: vrops_appliances
become: no
gather_facts: False
roles:
- nmshadey.vmware_deploy_vrops
EOF
fi
if [ ! -z "$groups_vidm" ]; then
touch vmware_deploy_vidm.yml
cat <<EOF > vmware_deploy_vidm.yml
---
- hosts: vidm_appliances
become: no
gather_facts: False
roles:
- nmshadey.vmware_deploy_vidm
EOF
fi
if [ ! -z "$groups_vesxi" ]; then
touch vmware_deploy_vesxi.yml
cat <<EOF > vmware_deploy_vesxi.yml
---
- hosts: vesxi_hosts
become: no
gather_facts: False
roles:
- nmshadey.vmware_deploy_vesxi
EOF
fi
if [ ! -z "$groups_pesxi" ]; then
touch vmware_deploy_pesxi.yml
cat <<EOF > vmware_deploy_pesxi.yml
---
- hosts: pesxi_hosts
become: no
gather_facts: False
roles:
- nmshadey.vmware_deploy_pesxi
EOF
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment