Ensure tasks don't get set to changed uselessly

This commit is contained in:
dogeystamp 2022-03-04 09:02:48 -05:00
parent d7876c6a65
commit 77ef40aae6
Signed by: dogeystamp
GPG Key ID: 7225FE3592EFFA38
2 changed files with 16 additions and 3 deletions

View File

@ -49,6 +49,7 @@
ifname: "{{ interface }}" ifname: "{{ interface }}"
type: ethernet type: ethernet
register: nmcli_conf register: nmcli_conf
changed_when: false
poll: 0 poll: 0
async: 1000 async: 1000

View File

@ -9,6 +9,10 @@
dest: /etc/gitea/app.ini dest: /etc/gitea/app.ini
notify: Restart gitea notify: Restart gitea
- name: Set data path
set_fact:
data_path: "{{ dataroot }}/gitea/"
- name: Change systemd unit file to allow access to dataroot - name: Change systemd unit file to allow access to dataroot
lineinfile: lineinfile:
path: /usr/lib/systemd/system/gitea.service path: /usr/lib/systemd/system/gitea.service
@ -20,28 +24,36 @@
- name: Find owner of data folder - name: Find owner of data folder
stat: stat:
path: "{{ dataroot }}/gitea/" path: "{{ data_path }}"
register: data_folder register: data_folder
- name: Ensure data folder is under correct owner - name: Ensure data folder is under correct owner
file: file:
path: "{{ dataroot }}/gitea/" path: "{{ data_path }}"
state: directory state: directory
recurse: yes recurse: yes
owner: gitea owner: gitea
group: gitea group: gitea
when: data_folder.stat.pw_name != "gitea" when: data_folder.stat.pw_name != "gitea"
- name: Get gitea user information
user:
name: gitea
state: present
register: gitea_user
- name: Ensure gitea is stopped - name: Ensure gitea is stopped
service: service:
name: gitea name: gitea
state: stopped state: stopped
when: gitea_user.home != data_path[:-1]
- name: Change homedir of gitea - name: Change homedir of gitea
user: user:
name: gitea name: gitea
home: "{{ dataroot }}/gitea/" home: "{{ data_path }}"
notify: Restart gitea notify: Restart gitea
when: gitea_user.home != data_path[:-1]
- name: Enable gitea - name: Enable gitea
service: service: