From 765623d46f1f59ca83e8ddb7508aebb345ad4c72 Mon Sep 17 00:00:00 2001 From: Derek Higgins Date: Wed, 16 Jan 2013 05:09:39 -0500 Subject: [PATCH] Adding homedir custom fact The location of the keystonerc_admin file was hard coded to /root, this sometimes is not the home directory of root. We need a custom facter fact to get the correct home directory. This commit o adds a facts directory to contain facter facts o adds a home_dir fact o uses this new fact for the location of the file keystonerc_admin Change-Id: Ifb7003072939d4c95f8ee65b721bfe31311d298c --- packstack/plugins/puppet_950.py | 3 ++- packstack/puppet/facts/home_dir.rb | 8 ++++++++ packstack/puppet/templates/openstack_client.pp | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 packstack/puppet/facts/home_dir.rb diff --git a/packstack/plugins/puppet_950.py b/packstack/plugins/puppet_950.py index 474d772ec..add1ba3a8 100644 --- a/packstack/plugins/puppet_950.py +++ b/packstack/plugins/puppet_950.py @@ -78,7 +78,7 @@ def copyPuppetModules(): tar_opts += "--exclude create_resources " for hostname in gethostlist(controller.CONF): server.append("cd %s/puppet" % basedefs.DIR_PROJECT_DIR) - server.append("tar %s --dereference -czf - modules | ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@%s tar -C %s -xzf -" % (tar_opts, hostname, basedefs.VAR_DIR)) + server.append("tar %s --dereference -czf - modules facts | ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@%s tar -C %s -xzf -" % (tar_opts, hostname, basedefs.VAR_DIR)) server.append("cd %s" % basedefs.PUPPET_MANIFEST_DIR) server.append("tar %s --dereference -czf - ../manifests | ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@%s tar -C %s -xzf -" % (tar_opts, hostname, basedefs.VAR_DIR)) server.execute() @@ -132,6 +132,7 @@ def applyPuppetManifest(): logfile = "%s.log" % manifest currently_running.append((hostname, logfile)) command = "( flock %s/ps.lock puppet apply --modulepath %s/modules %s > %s_ 2>&1 < /dev/null ; mv %s_ %s ) > /dev/null 2>&1 < /dev/null &" % (basedefs.VAR_DIR, basedefs.VAR_DIR, manifest, logfile, logfile, logfile) + server.append("export FACTERLIB=%s/facts"%basedefs.VAR_DIR) server.append(command) server.execute() diff --git a/packstack/puppet/facts/home_dir.rb b/packstack/puppet/facts/home_dir.rb new file mode 100644 index 000000000..1e2745264 --- /dev/null +++ b/packstack/puppet/facts/home_dir.rb @@ -0,0 +1,8 @@ + +# Current users home directory + +Facter.add("home_dir") do + setcode do + Facter::Util::Resolution.exec('/bin/echo $HOME') + end +end diff --git a/packstack/puppet/templates/openstack_client.pp b/packstack/puppet/templates/openstack_client.pp index fbb5f5591..fec9627be 100644 --- a/packstack/puppet/templates/openstack_client.pp +++ b/packstack/puppet/templates/openstack_client.pp @@ -7,7 +7,7 @@ package {"clientlibs": name => ["python-novaclient", "python-keystoneclient", "python-glanceclient", "python-swiftclient", "python-cinderclient"] } -file {"/root/keystonerc_admin": +file {"${::home_dir}/keystonerc_admin": ensure => "present", content => "export OS_USERNAME=admin export OS_TENANT_NAME=admin