Refactor collection

This commit is contained in:
Tobias Reisinger 2024-04-30 12:39:24 +02:00
parent 39dcd749a0
commit f615c00fdb
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE
17 changed files with 44 additions and 39 deletions

View file

@ -1,6 +1,6 @@
- name: Burn img to device
ansible.builtin.command:
cmd: dd if="{{ dietpi_img}}.img" of="{{ dietpi_device }}" bs=4M status=progress
cmd: dd if="{{ dietpi.img}}.img" of="{{ dietpi_device }}" bs=4M status=progress
chdir: "{{ build_dir.path }}"
become: true
register: cmd_result

View file

@ -0,0 +1,9 @@
- name: Download iso
ansible.builtin.get_url:
url: "{{ dietpi_download_base }}/{{ dietpi.img }}.7z"
dest: "{{ (lookup('ansible.builtin.env', 'XDG_RUNTIME_DIR'), dietpi.img + '.xz') | path_join }}"
- name: Extract iso
ansible.builtin.command:
#cmd: 7z x -y -o"{{ build_dir.path }}" "{{ (lookup('ansible.builtin.env', 'XDG_RUNTIME_DIR'), dietpi.img + '.7z') | path_join }}"
cmd: xz -d "{{ (lookup('ansible.builtin.env', 'XDG_RUNTIME_DIR'), dietpi.img + '.xz') | path_join }}"

View file

@ -2,5 +2,7 @@
- import_tasks: prepare_facts.yml
- import_tasks: prepare_directory.yml
- import_tasks: download_iso.yml
when: dietpi_reconfig is undefined or not dietpi_reconfig
- import_tasks: burn_to_device.yml
when: dietpi_reconfig is undefined or not dietpi_reconfig
- import_tasks: template_configs.yml

View file

@ -2,9 +2,11 @@
ansible.builtin.pause:
prompt: "Input device to install dietpi on"
register: dietpi_device_prompt
when: dietpi_device is undefined
- name: Set dietpi_device
ansible.builtin.set_fact:
dietpi_device: "{{ dietpi_device_prompt.user_input }}"
when: dietpi_device is undefined
- name: Check dietpi device
ansible.builtin.command:
cmd: test -b {{ dietpi_device }}

View file

@ -29,7 +29,7 @@
ansible.builtin.template:
src: dietpi-wifi.txt.j2
dest: "{{ (config_path, 'dietpi-wifi.txt') | path_join }}"
when: wifi_enabled | default(False)
when: dietpi.auto_setup.net_wifi_enabled | default(False)
become: true
- name: Try to copy Automation_Custom_Script.sh

View file

@ -0,0 +1,24 @@
{% for wifi in dietpi.wifi %}
#---------------------------------------------------------------
# Entry {{ loop.index }}
# - WiFi SSID: required, case sensitive
aWIFI_SSID[{{ loop.index }}]='{{ wifi.ssid }}'
# - WiFi key: If no key/open, leave this blank
# - In case of WPA-PSK, alternatively enter the 64-digit hexadecimal key returned by wpa_passphrase
# - Please replace single quote characters ' in your key with '\''. No other escaping is required.
aWIFI_KEY[{{ loop.index }}]='{{ wifi.key|default('') }}'
# - Key type: NONE (no key/open) | WPA-PSK | WEP | WPA-EAP (then use settings below)
aWIFI_KEYMGR[{{ loop.index }}]='{{ wifi.keymgr|default('NONE') }}'
# - WPA-EAP options: Only fill if WPA-EAP is set above
aWIFI_PROTO[{{ loop.index }}]='{{ wifi.proto|default('') }}'
aWIFI_PAIRWISE[{{ loop.index }}]='{{ wifi.pairwise|default('') }}'
aWIFI_AUTH_ALG[{{ loop.index }}]='{{ wifi.auth_alg|default('') }}'
aWIFI_EAP[{{ loop.index }}]='{{ wifi.eap|default('') }}'
aWIFI_IDENTITY[{{ loop.index }}]='{{ wifi.identity|default('') }}'
aWIFI_PASSWORD[{{ loop.index }}]='{{ wifi.password|default('') }}'
aWIFI_PHASE1[{{ loop.index }}]='{{ wifi.phase1|default('') }}'
aWIFI_PHASE2[{{ loop.index }}]='{{ wifi.phase2|default('') }}'
# - Path to the certificate file, e.g.: /boot/mycert.cer
aWIFI_CERT[{{ loop.index }}]='{{ wifi.cert|default('') }}'
{% endfor %}
#---------------------------------------------------------------

View file

@ -196,7 +196,7 @@ CONFIG_CHECK_APT_UPDATES={{ diet.config.check_apt_updates|default(1) }}
CONFIG_NTP_MODE={{ diet.config.ntp_mode|default(2) }}
# Serial Console: Set to 0 if you do not require serial console.
CONFIG_SERIAL_CONSOLE_ENABLE={{ diet.config.serial_console_enable|default(1) }}
CONFIG_SERIAL_CONSOLE_ENABLE={{ diet.config.serial_console_enable|default(true) | ternary(1, 0) }}
# Sound card
CONFIG_SOUNDCARD={{ diet.config.soundcard|default('none') }}

View file

@ -1,8 +0,0 @@
- name: Download iso
ansible.builtin.get_url:
url: "{{ dietpi_download_base }}/{{ dietpi_img }}.7z"
dest: "{{ (lookup('ansible.builtin.env', 'XDG_RUNTIME_DIR'), dietpi_img + '.7z') | path_join }}"
- name: Extract iso
ansible.builtin.command:
cmd: 7z x -y -o"{{ build_dir.path }}" "{{ (lookup('ansible.builtin.env', 'XDG_RUNTIME_DIR'), dietpi_img + '.7z') | path_join }}"

View file

@ -1,24 +0,0 @@
{% foreach dietpi.wifi as index => wifi %}
#---------------------------------------------------------------
# Entry {{ index }}
# - WiFi SSID: required, case sensitive
aWIFI_SSID[{{ index }}]='{{ wifi.ssid }}'
# - WiFi key: If no key/open, leave this blank
# - In case of WPA-PSK, alternatively enter the 64-digit hexadecimal key returned by wpa_passphrase
# - Please replace single quote characters ' in your key with '\''. No other escaping is required.
aWIFI_KEY[{{ index }}]='{{ wifi.key|default('') }}'
# - Key type: NONE (no key/open) | WPA-PSK | WEP | WPA-EAP (then use settings below)
aWIFI_KEYMGR[{{ index }}]='{{ wifi.keymgr|default('NONE') }}'
# - WPA-EAP options: Only fill if WPA-EAP is set above
aWIFI_PROTO[{{ index }}]='{{ wifi.proto|default('') }}'
aWIFI_PAIRWISE[{{ index }}]='{{ wifi.pairwise|default('') }}'
aWIFI_AUTH_ALG[{{ index }}]='{{ wifi.auth_alg|default('') }}'
aWIFI_EAP[{{ index }}]='{{ wifi.eap|default('') }}'
aWIFI_IDENTITY[{{ index }}]='{{ wifi.identity|default('') }}'
aWIFI_PASSWORD[{{ index }}]='{{ wifi.password|default('') }}'
aWIFI_PHASE1[{{ index }}]='{{ wifi.phase1|default('') }}'
aWIFI_PHASE2[{{ index }}]='{{ wifi.phase2|default('') }}'
# - Path to the certificate file, e.g.: /boot/mycert.cer
aWIFI_CERT[{{ index }}]='{{ wifi.cert|default('') }}'
{% endforeach %}
#---------------------------------------------------------------