Refactor collection
This commit is contained in:
		
							parent
							
								
									39dcd749a0
								
							
						
					
					
						commit
						f615c00fdb
					
				
					 17 changed files with 44 additions and 39 deletions
				
			
		
							
								
								
									
										10
									
								
								sbc/roles/dietpi_install/tasks/burn_to_device.yml
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								sbc/roles/dietpi_install/tasks/burn_to_device.yml
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,10 @@ | |||
| - name: Burn img to device | ||||
|   ansible.builtin.command: | ||||
|     cmd: dd if="{{ dietpi.img}}.img" of="{{ dietpi_device }}" bs=4M status=progress | ||||
|     chdir: "{{ build_dir.path }}" | ||||
|   become: true | ||||
|   register: cmd_result | ||||
| 
 | ||||
| - name: Debug dd result | ||||
|   ansible.builtin.debug: | ||||
|     var: cmd_result | ||||
							
								
								
									
										25
									
								
								sbc/roles/dietpi_install/tasks/copy_automation_script.yml
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								sbc/roles/dietpi_install/tasks/copy_automation_script.yml
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,25 @@ | |||
| --- | ||||
| - 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: wifi_enabled | default(False) | ||||
|   become: true | ||||
							
								
								
									
										9
									
								
								sbc/roles/dietpi_install/tasks/download_iso.yml
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								sbc/roles/dietpi_install/tasks/download_iso.yml
									
										
									
									
									
										Normal 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 }}" | ||||
| 
 | ||||
							
								
								
									
										8
									
								
								sbc/roles/dietpi_install/tasks/main.yml
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								sbc/roles/dietpi_install/tasks/main.yml
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,8 @@ | |||
| --- | ||||
| - 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 | ||||
							
								
								
									
										14
									
								
								sbc/roles/dietpi_install/tasks/prepare_directory.yml
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								sbc/roles/dietpi_install/tasks/prepare_directory.yml
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,14 @@ | |||
| - name: Create temporary build directory | ||||
|   ansible.builtin.tempfile: | ||||
|     state: directory | ||||
|     suffix: -emgauwa-system | ||||
|   register: build_dir | ||||
| - name: Print tmp path to user | ||||
|   ansible.builtin.debug: | ||||
|     var: build_dir.path | ||||
| 
 | ||||
| - name: Create mount dir in build directory | ||||
|   ansible.builtin.file: | ||||
|     path: "{{ (build_dir.path, 'mount') | path_join }}" | ||||
|     state: directory | ||||
|     mode: '0755' | ||||
							
								
								
									
										13
									
								
								sbc/roles/dietpi_install/tasks/prepare_facts.yml
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								sbc/roles/dietpi_install/tasks/prepare_facts.yml
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,13 @@ | |||
| - name: Prompt for device to install on | ||||
|   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 }} | ||||
|   changed_when: false | ||||
							
								
								
									
										50
									
								
								sbc/roles/dietpi_install/tasks/template_configs.yml
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										50
									
								
								sbc/roles/dietpi_install/tasks/template_configs.yml
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,50 @@ | |||
| --- | ||||
| - 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: 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 | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue