ansible-collections/sbc/roles/dietpi_install/tasks/template_configs.yml

59 lines
1.8 KiB
YAML

---
- name: Mount the boot directory
ansible.posix.mount:
src: "{{ dietpi_device }}1"
path: "{{ (build_dir.path, 'mount') | path_join }}"
fstype: auto
state: ephemeral
become: true
- name: Set default path to place configs
ansible.builtin.set_fact:
config_path: "{{ (build_dir.path, 'mount') | path_join }}"
- name: Check if dietpi.txt exists in root
ansible.builtin.stat:
path: "{{ (config_path, 'dietpi.txt') | path_join }}"
register: dietpi_config_file
- name: Set config path into boot directory
ansible.builtin.set_fact:
config_path: "{{ (config_path, 'boot') | path_join }}"
when: not dietpi_config_file.stat.exists
- name: Template dietpi.txt
ansible.builtin.template:
src: dietpi.txt.j2
dest: "{{ (config_path, 'dietpi.txt') | path_join }}"
become: true
- name: Template dietpi-wifi.txt
ansible.builtin.template:
src: dietpi-wifi.txt.j2
dest: "{{ (config_path, 'dietpi-wifi.txt') | path_join }}"
when: dietpi.auto_setup.net_wifi_enabled | default(False)
become: true
- name: Enable spi in config.txt
ansible.builtin.replace:
path: "{{ (config_path, 'config.txt') | path_join }}"
regexp: '^#dtparam=spi=off$'
replace: 'dtparam=spi=on'
become: true
when: dietpi.enable_spi | default(False)
- name: Try to copy Automation_Custom_Script.sh
ansible.builtin.copy:
src: Automation_Custom_Script.sh
dest: "{{ (config_path, 'Automation_Custom_Script.sh') | path_join }}"
ignore_errors: true
- name: Try to template Automation_Custom_Script.sh
ansible.builtin.template:
src: Automation_Custom_Script.sh.j2
dest: "{{ (config_path, 'Automation_Custom_Script.sh') | path_join }}"
ignore_errors: true
- name: Unmount the boot directory
ansible.posix.mount:
path: "{{ (build_dir.path, 'mount') | path_join }}"
state: unmounted
become: true