I'm not really sure what's going on (bit rusty in bash), but the following things to check on come to mind.
/bin/sh may not be linked to bash, and "export THING=whatever" is a bashism. It could be that "THING=whatever; export THING" will work better for you. However you're likely using something Linux so this doesn't count. Execs are going to run in a subshell and be separated at the process level from other execs. If you check the source builtin in the bash manual it says "in the current shell environment". You running source at the command line and then running puppet means that puppet will pick up environment settings from your current environment, whereas "bash -c" and the exec make the settings exist in a subshell. They will be contained to a single child PID and vanish when the exec is over. The documentation suggests that openrc.sh is sourced, so if you need to set up environment variables for the rest of the keystone setup a single exec definitely won't work. https://docs.openstack.org/liberty/install-guide-ubuntu/keystone-openrc.html#using-the-scripts In your place (with 100% less openstack experience than you) I would be provisioning openrc.sh as a file resource on the system, with 0600 permissions, and then ensuring that the keystone clients (handled elsewhere in puppet?) source that file, with their resources depending on the openrc.sh file resource so things were in the right order. On Sun, Apr 22, 2018 at 12:26:11AM -0700, Justin tim wrote: > Hi, > > I've been trying to setup openstack keystone for my DEV environment using > Puppet. Everything works fine, except the 'exec' resource. > > I have tried the below things, but not getting the desired results > > 1. '/bin/bash -c 'source /root/openrc.sh' in the command attribute, but > nothing happens. > 2. tried using the 'provider' attribute in the exec resource. > 3. tried using 'environment' attribute. > > It's only when i manually run 'source /root/openrc.sh', the variables are > set. > > Below are the contents of the actual puppet manifest, and the openrc.sh > file which is to be run on the node. > > # cat testexec.pp > > exec { 'admin': > command => '/bin/sh /root/openrc.sh' > > } > > Contents of openrc.sh > > #!/bin/sh > export OS_TOKEN="fbed3beb36960f2b3e1b" > export OS_URL="http://openstack:35357/v3" > export OS_IDENTITY_API_VERSION=3 > > Is there a way we achieve this? > > Thanks in Advance. > J > > -- > You received this message because you are subscribed to the Google Groups > "Puppet Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [1]puppet-users+unsubscr...@googlegroups.com. > To view this discussion on the web visit > > [2]https://groups.google.com/d/msgid/puppet-users/05c9d71f-c02d-4d5a-8607-70ecbf68dafe%40googlegroups.com. > For more options, visit [3]https://groups.google.com/d/optout. > > References > > Visible links > 1. mailto:puppet-users+unsubscr...@googlegroups.com > 2. > https://groups.google.com/d/msgid/puppet-users/05c9d71f-c02d-4d5a-8607-70ecbf68dafe%40googlegroups.com?utm_medium=email&utm_source=footer > 3. https://groups.google.com/d/optout -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/20180422115546.l7h3bokrsro7p4oz%40iniquitous.heresiarch.ca. For more options, visit https://groups.google.com/d/optout.