fix(common): replace deprecated ansible_ fact references with ansible_facts[]

This commit is contained in:
Tuan-Dat Tran
2026-06-03 02:17:08 +02:00
parent aa8b591afd
commit 956836dc67
6 changed files with 28 additions and 28 deletions

View File

@@ -2,9 +2,9 @@
- name: Copy bash-configs
ansible.builtin.template:
src: "files/bash/{{ item }}"
dest: "{{ ansible_env.HOME }}/.{{ item }}"
owner: "{{ ansible_user_id }}"
group: "{{ ansible_user_id }}"
dest: "{{ ansible_facts['env']['HOME'] }}/.{{ item }}"
owner: "{{ ansible_facts['user_id'] }}"
group: "{{ ansible_facts['user_id'] }}"
mode: "644"
loop:
- bashrc
@@ -13,25 +13,25 @@
- name: Copy ghostty infocmp
ansible.builtin.copy:
src: files/ghostty/infocmp
dest: "{{ ansible_env.HOME }}/ghostty"
owner: "{{ ansible_user_id }}"
group: "{{ ansible_user_id }}"
dest: "{{ ansible_facts['env']['HOME'] }}/ghostty"
owner: "{{ ansible_facts['user_id'] }}"
group: "{{ ansible_facts['user_id'] }}"
mode: "0644"
register: ghostty_terminfo
- name: Compile ghostty terminalinfo
ansible.builtin.command: "tic -x {{ ansible_env.HOME }}/ghostty"
ansible.builtin.command: "tic -x {{ ansible_facts['env']['HOME'] }}/ghostty"
when: ghostty_terminfo.changed
- name: Copy kitty infocmp
ansible.builtin.copy:
src: files/kitty/infocmp
dest: "{{ ansible_env.HOME }}/kitty"
owner: "{{ ansible_user_id }}"
group: "{{ ansible_user_id }}"
dest: "{{ ansible_facts['env']['HOME'] }}/kitty"
owner: "{{ ansible_facts['user_id'] }}"
group: "{{ ansible_facts['user_id'] }}"
mode: "0644"
register: kitty_terminfo
- name: Compile kitty terminalinfo
ansible.builtin.command: "tic -x {{ ansible_env.HOME }}/kitty"
ansible.builtin.command: "tic -x {{ ansible_facts['env']['HOME'] }}/kitty"
when: kitty_terminfo.changed

View File

@@ -37,21 +37,21 @@
register: neovim_installed
changed_when: false
ignore_errors: true
when: ansible_architecture != 'aarch64'
when: ansible_facts['architecture'] != 'aarch64'
- name: Download Neovim AppImage
ansible.builtin.get_url:
url: https://github.com/neovim/neovim/releases/download/v0.10.0/nvim.appimage
dest: /tmp/nvim.appimage
mode: "0755"
when: ansible_architecture != 'aarch64' and neovim_installed.rc != 0
when: ansible_facts['architecture'] != 'aarch64' and neovim_installed.rc != 0
register: download_result
- name: Extract Neovim AppImage
ansible.builtin.command:
cmd: "./nvim.appimage --appimage-extract"
chdir: /tmp
when: ansible_architecture != 'aarch64' and download_result.changed
when: ansible_facts['architecture'] != 'aarch64' and download_result.changed
register: extract_result
- name: Copy extracted Neovim files to /usr
@@ -61,19 +61,19 @@
remote_src: true
mode: "0755"
become: true
when: ansible_architecture != 'aarch64' and extract_result.changed
when: ansible_facts['architecture'] != 'aarch64' and extract_result.changed
- name: Clean up extracted Neovim files
ansible.builtin.file:
path: /tmp/squashfs-root
state: absent
when: ansible_architecture != 'aarch64' and extract_result.changed
when: ansible_facts['architecture'] != 'aarch64' and extract_result.changed
- name: Remove Neovim AppImage
ansible.builtin.file:
path: /tmp/nvim.appimage
state: absent
when: ansible_architecture != 'aarch64' and download_result.changed
when: ansible_facts['architecture'] != 'aarch64' and download_result.changed
- name: Check if Neovim config directory already exists
ansible.builtin.stat:

View File

@@ -5,24 +5,24 @@
upgrade: true
autoremove: true
become: true
when: ansible_user_id != "root"
when: ansible_facts['user_id'] != "root"
- name: Install base packages
ansible.builtin.apt:
name: "{{ common_packages }}"
state: present
become: true
when: ansible_user_id != "root"
when: ansible_facts['user_id'] != "root"
- name: Update and upgrade packages
ansible.builtin.apt:
update_cache: true
upgrade: true
autoremove: true
when: ansible_user_id == "root"
when: ansible_facts['user_id'] == "root"
- name: Install base packages
ansible.builtin.apt:
name: "{{ common_packages }}"
state: present
when: ansible_user_id == "root"
when: ansible_facts['user_id'] == "root"

View File

@@ -8,7 +8,7 @@
notify:
- Restart sshd
become: true
when: ansible_user_id != "root"
when: ansible_facts['user_id'] != "root"
- name: Copy root sshd_config
ansible.builtin.template:
@@ -18,7 +18,7 @@
backup: true
notify:
- Restart sshd
when: ansible_user_id == "root"
when: ansible_facts['user_id'] == "root"
- name: Copy pubkey
ansible.builtin.copy:

View File

@@ -3,12 +3,12 @@
community.general.timezone:
name: "{{ timezone }}"
become: true
when: ansible_user_id != "root"
when: ansible_facts['user_id'] != "root"
- name: Set timezone
community.general.timezone:
name: "{{ timezone }}"
when: ansible_user_id == "root"
when: ansible_facts['user_id'] == "root"
- name: Configure NTP servers for systemd-timesyncd
ansible.builtin.lineinfile:
@@ -24,11 +24,11 @@
enabled: true
state: started
become: true
when: ansible_user_id != "root"
when: ansible_facts['user_id'] != "root"
- name: Enable and start systemd-timesyncd
ansible.builtin.systemd:
name: systemd-timesyncd
enabled: true
state: started
when: ansible_user_id == "root"
when: ansible_facts['user_id'] == "root"

View File

@@ -19,7 +19,7 @@ nfs_server: 192.168.20.12
# Packages
#
arch: "{{ 'arm64' if ansible_architecture == 'aarch64' else 'amd64' }}"
arch: "{{ 'arm64' if ansible_facts['architecture'] == 'aarch64' else 'amd64' }}"
netcup_api_key: "{{ vault_netcup.api_key }}"
netcup_api_password: "{{ vault_netcup.api_password }}"