Does shell provisioner source .bashrc or .bash_profile?

Im using multiple shell provisioners with vagrant. The first shell provisioner sets some environment variables within \~/.bashrc and \~/.bash\_profile like `export HTTP_PROXY=""`. But for the following provisioners the environment variables are not set or empty. So are the shell provisioners neither using login nor non-login shells to source .bashrc or .bash\_profile? But also using `source ~/.bashrc` within the shell script itself does not work. When i log in all environment variables are set.

1 thought on “Does shell provisioner source .bashrc or .bash_profile?”

  1. Backslashes in a URL (HTTP_PROXY)? Might want to look into that.

    Here is a small demo that shows which files are sourced during shell provisioning:

    Vagrant.configure(“2”) do |config| = “generic/ubuntu1810”

    config.vm.provision “shell”, inline: <<-SHELL env|grep TEST_ echo 'export TEST_BASHRC="this is root .bashrc"' >> /root/.bashrc
    echo ‘export TEST_BASHPROFILE=”this is root .bash_profile”‘ >> /root/.bash_profile

    echo ‘export TEST_BASHRC=”this is vagrant .bashrc”‘ >> /home/vagrant/.bashrc
    echo ‘export TEST_BASHPROFILE=”this is vagrant .bash_profile”‘ >> /home/vagrant/.bash_profile

    echo ‘export TEST_ETCPROFILE=”this is /etc/profile.d/”‘ > /etc/profile.d/

    config.vm.provision “shell”, inline: <<-SHELL env|grep TEST_ SHELL config.vm.provision "shell", inline: <<-SHELL env|grep TEST_ SHELL end


Leave a Comment