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="http://127.0.0.1"`. 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|
    config.vm.box = “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/local.sh”‘ > /etc/profile.d/local.sh
    SHELL

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

    Reply

Leave a Comment