Skip to content

Commit df5e74a

Browse files
committed
create /var/cache/downloads directory via systemd-tmpfiles
1 parent b34e592 commit df5e74a

4 files changed

Lines changed: 23 additions & 0 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Other tweaks and settings worth mentioning:
3535
* sets up `~/.bashrc.d` directory to ease management of bash initialization (e.g. for setting env vars)
3636
* adds a Git `PS1` shell prompt and configures some useful aliases and settings in `~/.gitconfig`
3737
* symlinks [`update-vm.sh`](scripts/update-vm.sh) to `/usr/local/bin/update-vm` so it's in the `$PATH` and can be used for updating the VM from the inside (see below)
38+
* adds `/var/cache/downloads` as a cache directory for downloaded installer files
3839

3940

4041
## Usage

roles/cache/tasks/main.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
3+
- name: Add systemd-tmpfiles configuration for /var/cache/downloads
4+
copy:
5+
content: |
6+
# See tmpfiles.d(5) for details
7+
8+
# Create a download cache directory without automatic deletion
9+
d /var/cache/downloads 1777 root root -
10+
dest: /etc/tmpfiles.d/downloads.conf
11+
mode: 0644
12+
register: download_cache
13+
14+
- name: Trigger systemd to create /var/cache/downloads
15+
command:
16+
cmd: systemd-tmpfiles --create
17+
creates: /var/cache/downloads
18+
when: download_cache.changed

site.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@
1313
- { role: ansible-lint, tags: "ansible-lint" }
1414
- { role: testinfra, tags: "testinfra" }
1515
- { role: bashrc_d, tags: "bashrc_d" }
16+
- { role: cache, tags: "cache" }
1617
- { role: git, tags: "git" }
1718
- { role: vscode, tags: "vscode" }

spec/test_cache.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
def test_download_cache_directory_exists_(host):
3+
assert host.file('/var/cache/downloads').is_directory

0 commit comments

Comments
 (0)