File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ---
2+ - name : create ~/.bashrc.d directory
3+ file :
4+ path : ~/.bashrc.d
5+ state : directory
6+ mode : 0755
7+ become : yes
8+ become_user : " {{ ansible_env.SUDO_USER }}"
9+
10+ - name : Setup ~/.bashrc to load .bash files from ~/.bashrc.d
11+ blockinfile :
12+ dest : ~/.bashrc
13+ block : |
14+ # Load *.bash files from ~/.bashrc.d
15+ for config in "$HOME"/.bashrc.d/*.bash ; do
16+ . "$config"
17+ done
18+ unset -v config
19+ become : yes
20+ become_user : " {{ ansible_env.SUDO_USER }}"
Original file line number Diff line number Diff line change 1111 path : ~/Desktop
1212 state : directory
1313 mode : 0755
14-
1514 become : yes
1615 become_user : " {{ ansible_env.SUDO_USER }}"
1716
Original file line number Diff line number Diff line change 1212 - { role: readme, tags: "readme" }
1313 - { role: ansible-lint, tags: "ansible-lint" }
1414 - { role: testinfra, tags: "testinfra" }
15+ - { role: bashrc_d, tags: "bashrc_d" }
Original file line number Diff line number Diff line change 1+ import textwrap
2+ import os
3+
4+ def test_bashrc_loads_files_from_bashrc_d_ (host ):
5+ bashrc = host .file (f"{ os .environ ['HOME' ]} /.bashrc" )
6+ snippet = textwrap .dedent (
7+ '''
8+ # Load *.bash files from ~/.bashrc.d
9+ for config in "$HOME"/.bashrc.d/*.bash ; do
10+ . "$config"
11+ done
12+ unset -v config
13+ '''
14+ )
15+ assert snippet in bashrc .content_string
You can’t perform that action at this time.
0 commit comments