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

View File

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

View File

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

View File

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

View File

@@ -3,12 +3,12 @@
community.general.timezone: community.general.timezone:
name: "{{ timezone }}" name: "{{ timezone }}"
become: true become: true
when: ansible_user_id != "root" when: ansible_facts['user_id'] != "root"
- name: Set timezone - name: Set timezone
community.general.timezone: community.general.timezone:
name: "{{ timezone }}" name: "{{ timezone }}"
when: ansible_user_id == "root" when: ansible_facts['user_id'] == "root"
- name: Configure NTP servers for systemd-timesyncd - name: Configure NTP servers for systemd-timesyncd
ansible.builtin.lineinfile: ansible.builtin.lineinfile:
@@ -24,11 +24,11 @@
enabled: true enabled: true
state: started state: started
become: true become: true
when: ansible_user_id != "root" when: ansible_facts['user_id'] != "root"
- name: Enable and start systemd-timesyncd - name: Enable and start systemd-timesyncd
ansible.builtin.systemd: ansible.builtin.systemd:
name: systemd-timesyncd name: systemd-timesyncd
enabled: true enabled: true
state: started 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 # 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_key: "{{ vault_netcup.api_key }}"
netcup_api_password: "{{ vault_netcup.api_password }}" netcup_api_password: "{{ vault_netcup.api_password }}"