I am trying to append several environment variables to the .bashrc
file on a server:
- name: append environment variables to the end of .bashrc file
blockinfile:
dest: "/home/username/.bashrc"
insertafter: EOF
block: |
# environment variable exports
export something="something";
Running the above results in the following error:
fatal: [ip-address]: FAILED! => {"changed": false, "msg": "Path /home/username/.bashrc does not exist !", "rc": 257}
If I change the path from /home/username/.bashrc
to ~/.bashrc
the playbook is successful, however when I log into the server with the relevant user, the .bashrc
has not been updated.
Ansible version: 2.5.1 Server OS: Ubuntu 16.04
Is there another file I should be using instead of .bashrc
to append environment variables to for the specified user (which is the same user that I am running the ansible-playbook
as)?
The goal is to add the environment variables and then in a separate task, source
the file to make the environment variables available permanently for that user.