support targeting localhost
when targeting localhost, synthesize an initial inventory file before calling ansible. this resolves #36. Change-Id: I6459de70db2a912a348fe0cec5c49240abaa4687
This commit is contained in:
@@ -17,10 +17,9 @@
|
||||
# We need to force-refresh facts because we are now connecting
|
||||
# as a different user ('stack' instead of 'root'), which affects
|
||||
# things like ansible_user_id and friends.
|
||||
- name: Install libvirt packages and configure networks
|
||||
- name: Tear down environment
|
||||
hosts: virthost
|
||||
pre_tasks:
|
||||
- setup:
|
||||
roles:
|
||||
- environment/teardown
|
||||
- environment/setup
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
---
|
||||
- include: provision.yml
|
||||
tags:
|
||||
- provision
|
||||
|
||||
- name: Install libvirt packages and configure networks
|
||||
hosts: virthost
|
||||
tags:
|
||||
- environment
|
||||
roles:
|
||||
- environment/setup
|
||||
|
||||
- name: Setup undercloud and baremetal vms and networks in libvirt
|
||||
hosts: virthost
|
||||
@@ -8,9 +17,10 @@
|
||||
- libvirt/teardown
|
||||
- libvirt/setup
|
||||
|
||||
# This adds the undercloud node to the generated
|
||||
# inventory.
|
||||
- name: Rebuild inventory
|
||||
hosts: localhost
|
||||
gather_facts: no
|
||||
roles:
|
||||
- rebuild-inventory
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
- name: Add the virthost to the inventory
|
||||
add_host:
|
||||
name: "host0"
|
||||
name: "{{virthost}}"
|
||||
groups: "virthost"
|
||||
ansible_fqdn: "{{ virthost }}"
|
||||
ansible_user: "root"
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
|
||||
- name: Re-add the virthost to the inventory
|
||||
add_host:
|
||||
name: "host0"
|
||||
name: "{{ virthost }}"
|
||||
groups: "virthost"
|
||||
ansible_fqdn: "{{ virthost }}"
|
||||
ansible_user: "{{ non_root_user }}"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
DEFAULT_OPT_TAGS="untagged,undercloud-scripts,overcloud-scripts"
|
||||
DEFAULT_OPT_TAGS="untagged,provision,undercloud-scripts,overcloud-scripts"
|
||||
|
||||
: ${OPT_BOOTSTRAP:=0}
|
||||
: ${OPT_SYSTEM_PACKAGES:=0}
|
||||
@@ -63,6 +63,7 @@ usage () {
|
||||
echo " --working-dir <directory>"
|
||||
echo " --undercloud-image-url <url>"
|
||||
echo " --tags <tag1>[,<tag2>,...]"
|
||||
echo " --skip-tags <tag1>,[<tag2>,...]"
|
||||
echo " --config <file>"
|
||||
}
|
||||
|
||||
@@ -100,6 +101,11 @@ while [ "x$1" != "x" ]; do
|
||||
shift
|
||||
;;
|
||||
|
||||
--skip-tags)
|
||||
OPT_SKIP_TAGS=$2
|
||||
shift
|
||||
;;
|
||||
|
||||
--config|-c)
|
||||
OPT_CONFIG=$2
|
||||
shift
|
||||
@@ -205,6 +211,14 @@ set -ex
|
||||
export ANSIBLE_CONFIG=$OOOQ_DIR/ansible.cfg
|
||||
export ANSIBLE_INVENTORY=$OPT_WORKDIR/hosts
|
||||
|
||||
if [ "$VIRTHOST" = "localhost" ]; then
|
||||
echo "$0: WARNING: VIRTHOST == localhost; skipping provisioning" >&2
|
||||
OPT_SKIP_TAGS="${OPT_SKIP_TAGS:+$OPT_SKIP_TAGS,}provision"
|
||||
|
||||
echo "[virthost]" > $ANSIBLE_INVENTORY
|
||||
echo "localhost ansible_connection=local" >> $ANSIBLE_INVENTORY
|
||||
fi
|
||||
|
||||
if [ "$OPT_DEBUG_ANSIBLE" = 1 ]; then
|
||||
VERBOSITY=vvvv
|
||||
else
|
||||
@@ -217,7 +231,8 @@ ansible-playbook -$VERBOSITY $OOOQ_DIR/playbooks/quickstart.yml \
|
||||
-e image_url=$OPT_UNDERCLOUD_URL \
|
||||
-e local_working_dir=$OPT_WORKDIR \
|
||||
-e virthost=$VIRTHOST \
|
||||
${OPT_TAGS:+-t $OPT_TAGS}
|
||||
${OPT_TAGS:+-t $OPT_TAGS} \
|
||||
${OPT_SKIP_TAGS:+--skip-tags $OPT_SKIP_TAGS}
|
||||
|
||||
# We only print out further usage instructions when using the default
|
||||
# tags, since this is for new users (and not even applicable to some tags).
|
||||
|
||||
Reference in New Issue
Block a user