This repository has been archived by the owner on Nov 5, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
/
awx-migrate-wrapper
executable file
·62 lines (51 loc) · 1.7 KB
/
awx-migrate-wrapper
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash
# c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t
# vi: set shiftwidth=4 tabstop=4 noexpandtab:
# :indentSize=4:tabSize=4:noTabs=false:
set -o nounset
set -o errexit
set -o pipefail
if ! which jq >/dev/null
then
echo "Please install the jq commandline JSON processor!"
exit 1
fi
## overrule where needed
#export AWX_SRC_SECRET_KEY='awxsecret'
#export AWX_SRC_DBNAME='awx'
#export AWX_SRC_DBUSER='awx'
#export AWX_SRC_DBPASSWORD='awxpass'
#export AWX_SRC_DBHOST='localhost'
#export AWX_SRC_DBPORT='5432'
#export AWX_SRC_DATA_CACHE='awx-data.pickle'
#export AWX_DST_SECRET_KEY='awxsecret'
#export AWX_DST_DBNAME='awx'
#export AWX_DST_DBUSER='awx'
#export AWX_DST_DBPASSWORD='awxpass'
#export AWX_DST_DBHOST='localhost'
#export AWX_DST_DBPORT='5433'
## constants
datafbase="awx-data"
datafile="${datafbase}.json"
./awx-migrate > "${datafile}"
echo "AWX settings were migrated, except passwords. Update those manually: E.g.:
# tower-cli setting set AUTH_LDAP_BIND_PASSWORD '53cr37'
"
# Best order to restore?
AWX_OBJECTS="user organization team credential_type credential notification_template inventory_script project inventory job_template workflow "
echo
echo "To restore, run:"
echo
echo " tower-cli send ${datafbase}.json"
echo
echo "Or, restore only specific objects, or in paritcular order with one of:"
echo
for obj in ${AWX_OBJECTS}
do
jq "[ .[] | select(.asset_type==\"${obj}\") ]" "${datafile}" > "${datafbase}-${obj}.json"
echo " tower-cli send ${datafbase}-${obj}.json"
done
echo
echo "Also filtering content of dynamic inventories (with sources) into []_filtered.json files."
echo
./awx-remove-dyninv-content "${datafbase}-inventory.json" > "${datafbase}-inventory-filtered.json"