Make passwords.yml file generation configurable
partially implements blueprint multiple-clouds Change-Id: I676c4245e6f058ffbed345970ee78d1750dd0f2f
This commit is contained in:
parent
6aa81433db
commit
e1b5b149f2
@ -12,6 +12,7 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
import argparse
|
||||||
import os
|
import os
|
||||||
import random
|
import random
|
||||||
import string
|
import string
|
||||||
@ -29,6 +30,15 @@ def generate_RSA(bits=2048):
|
|||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument(
|
||||||
|
'-p', '--passwords', type=str,
|
||||||
|
default=os.path.abspath('/etc/kolla/passwords.yml'),
|
||||||
|
help=('Path to the passwords yml file'))
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
passwords_file = os.path.expanduser(args.passwords)
|
||||||
|
|
||||||
# These keys should be random uuids
|
# These keys should be random uuids
|
||||||
uuid_keys = ['ceph_cluster_fsid', 'rbd_secret_uuid']
|
uuid_keys = ['ceph_cluster_fsid', 'rbd_secret_uuid']
|
||||||
|
|
||||||
@ -41,7 +51,7 @@ def main():
|
|||||||
# length of password
|
# length of password
|
||||||
length = 40
|
length = 40
|
||||||
|
|
||||||
with open('/etc/kolla/passwords.yml', 'r') as f:
|
with open(passwords_file, 'r') as f:
|
||||||
passwords = yaml.load(f.read())
|
passwords = yaml.load(f.read())
|
||||||
|
|
||||||
for k, v in passwords.items():
|
for k, v in passwords.items():
|
||||||
@ -67,7 +77,7 @@ def main():
|
|||||||
for n in range(length)
|
for n in range(length)
|
||||||
])
|
])
|
||||||
|
|
||||||
with open('/etc/kolla/passwords.yml', 'w') as f:
|
with open(passwords_file, 'w') as f:
|
||||||
f.write(yaml.dump(passwords, default_flow_style=False))
|
f.write(yaml.dump(passwords, default_flow_style=False))
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
@ -28,14 +28,15 @@ function usage {
|
|||||||
Usage: $0 COMMAND [options]
|
Usage: $0 COMMAND [options]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
--inventory, -i <inventory_path> Specify path to ansible inventory file
|
--inventory, -i <inventory_path> Specify path to ansible inventory file
|
||||||
--playbook, -p <playbook_path> Specify path to ansible playbook file
|
--playbook, -p <playbook_path> Specify path to ansible playbook file
|
||||||
--configdir <config_path> Specify path to directory with globals.yml
|
--configdir <config_path> Specify path to directory with globals.yml
|
||||||
--keyfile, -k <key_file> Specify path to ansible vault keyfile
|
--keyfile, -k <key_file> Specify path to ansible vault keyfile
|
||||||
--help, -h Show this usage information
|
--help, -h Show this usage information
|
||||||
--tags, -t <tags> Only run plays and tasks tagged with these values
|
--tags, -t <tags> Only run plays and tasks tagged with these values
|
||||||
--extra, -e <ansible variables> Set additional variables as key=value or YAML/JSON passed to ansible-playbook
|
--extra, -e <ansible variables> Set additional variables as key=value or YAML/JSON passed to ansible-playbook
|
||||||
--verbose, -v Increase verbosity of ansible-playbook
|
--passwords <passwords_path> Specify path to the passwords file
|
||||||
|
--verbose, -v Increase verbosity of ansible-playbook
|
||||||
|
|
||||||
Commands:
|
Commands:
|
||||||
prechecks Do pre-deployment checks for hosts
|
prechecks Do pre-deployment checks for hosts
|
||||||
@ -53,7 +54,7 @@ EOF
|
|||||||
|
|
||||||
|
|
||||||
SHORT_OPTS="hi:p:t:k:e:v"
|
SHORT_OPTS="hi:p:t:k:e:v"
|
||||||
LONG_OPTS="help,inventory:,playbook:,tags:,keyfile:,extra:,verbose,configdir:"
|
LONG_OPTS="help,inventory:,playbook:,tags:,keyfile:,extra:,verbose,configdir:,passwords:,"
|
||||||
ARGS=$(getopt -o "${SHORT_OPTS}" -l "${LONG_OPTS}" --name "$0" -- "$@") || { usage >&2; exit 2; }
|
ARGS=$(getopt -o "${SHORT_OPTS}" -l "${LONG_OPTS}" --name "$0" -- "$@") || { usage >&2; exit 2; }
|
||||||
|
|
||||||
eval set -- "$ARGS"
|
eval set -- "$ARGS"
|
||||||
@ -65,6 +66,7 @@ PLAYBOOK="${BASEDIR}/ansible/site.yml"
|
|||||||
VERBOSITY=
|
VERBOSITY=
|
||||||
EXTRA_OPTS=
|
EXTRA_OPTS=
|
||||||
CONFIG_DIR="/etc/kolla"
|
CONFIG_DIR="/etc/kolla"
|
||||||
|
PASSWORDS_FILE="${CONFIG_DIR}/passwords.yml"
|
||||||
|
|
||||||
while [ "$#" -gt 0 ]; do
|
while [ "$#" -gt 0 ]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
@ -104,7 +106,10 @@ while [ "$#" -gt 0 ]; do
|
|||||||
EXTRA_OPTS="$EXTRA_OPTS -e $2"
|
EXTRA_OPTS="$EXTRA_OPTS -e $2"
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
|
(--passwords)
|
||||||
|
PASSWORDS_FILE="$2"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
(--help|-h)
|
(--help|-h)
|
||||||
usage
|
usage
|
||||||
shift
|
shift
|
||||||
@ -171,6 +176,6 @@ case "$1" in
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
CONFIG_OPTS="-e @${CONFIG_DIR}/globals.yml -e @${CONFIG_DIR}/passwords.yml -e CONFIG_DIR=${CONFIG_DIR}"
|
CONFIG_OPTS="-e @${CONFIG_DIR}/globals.yml -e @${PASSWORDS_FILE} -e CONFIG_DIR=${CONFIG_DIR}"
|
||||||
CMD="ansible-playbook -i $INVENTORY $CONFIG_OPTS $EXTRA_OPTS $PLAYBOOK $VERBOSITY"
|
CMD="ansible-playbook -i $INVENTORY $CONFIG_OPTS $EXTRA_OPTS $PLAYBOOK $VERBOSITY"
|
||||||
process_cmd
|
process_cmd
|
||||||
|
Loading…
Reference in New Issue
Block a user