fix failing download tasks.txt for gtimelog

* The download task failed, as the config directory was not created before, so a check for the directory was added to the playbook. If the check fails, the directory will be created for the user.
* The `ansible_env.USER` variable was used, as `ansible_user` was not available on the Debian 11 testing system.
* The initial `become: true` has been removed, as this was chaning the `USER` environment to `root` so that the user could not use the downloaded file

checked that this is running fine on a fresh install of Debian 11 in a VM.

fixes #1
This commit is contained in:
2022-11-17 13:10:09 +01:00
parent 3b58671604
commit 559a7d4917

View File

@@ -1,6 +1,5 @@
- name: Install packages - name: Install packages
hosts: all hosts: all
become: true
tasks: tasks:
- name: Stop packagekit - name: Stop packagekit
become: true become: true
@@ -41,11 +40,21 @@
ansible.builtin.apt: ansible.builtin.apt:
deb: /tmp/innernet.deb deb: /tmp/innernet.deb
- name: Check gtimelog directory is existing
become: false
file:
owner: "{{ ansible_env.USER }}"
group: "{{ ansible_env.USER }}"
path: "/home/{{ ansible_env.USER }}/.local/share/gtimelog/"
state: directory
mode: "755"
- name: Download tasks.txt for gtimelog - name: Download tasks.txt for gtimelog
tags: gtimelog tags: gtimelog
become: false
ansible.builtin.get_url: ansible.builtin.get_url:
url: https://git.fsfe.org/fsfe-system-hackers/staff-laptop/raw/branch/master/gtimelog/tasks.txt url: https://git.fsfe.org/fsfe-system-hackers/staff-laptop/raw/branch/master/gtimelog/tasks.txt
dest: "/home/{{ ansible_user }}/.local/share/gtimelog/tasks.txt" dest: "/home/{{ ansible_env.USER }}/.local/share/gtimelog/tasks.txt"
- name: Remove unneeded packages - name: Remove unneeded packages
become: true become: true