Add role for yq on Debina, macOS, and Windows
This commit is contained in:
		
							parent
							
								
									55cc3441be
								
							
						
					
					
						commit
						6a4a182cf5
					
				
							
								
								
									
										5
									
								
								roles/yq/tasks/Darwin.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								roles/yq/tasks/Darwin.yaml
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,5 @@ | |||||||
|  | --- | ||||||
|  | - name: install homebrew package | ||||||
|  |   homebrew: | ||||||
|  |     name: yq | ||||||
|  |     state: latest | ||||||
							
								
								
									
										37
									
								
								roles/yq/tasks/Debian.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								roles/yq/tasks/Debian.yaml
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,37 @@ | |||||||
|  | --- | ||||||
|  | - name: get latest github release | ||||||
|  |   uri: | ||||||
|  |     url: https://api.github.com/repos/mikefarah/yq/releases/latest | ||||||
|  |   register: latest | ||||||
|  | 
 | ||||||
|  | - set_fact: | ||||||
|  |     asset_query: '[?contains(name, `yq_linux_amd64`)] | [0]' | ||||||
|  |     assets: '{{latest.json.assets}}' | ||||||
|  |     latest_version: '{{latest.json.tag_name[1:]}}' | ||||||
|  |     yq_exe: '{{ansible_env.HOME}}/.local/bin/yq' | ||||||
|  | 
 | ||||||
|  | - name: check if alreayd installed | ||||||
|  |   stat: | ||||||
|  |     path: '{{yq_exe}}' | ||||||
|  |   register: yq_stat | ||||||
|  | 
 | ||||||
|  | - name: get installed version | ||||||
|  |   when: yq_stat.stat.exists == True | ||||||
|  |   command: '{{yq_exe}} --version' | ||||||
|  |   register: yq_version_output | ||||||
|  |   changed_when: false | ||||||
|  | 
 | ||||||
|  | - when: yq_stat.stat.exists == True | ||||||
|  |   set_fact: | ||||||
|  |     installed_version: | ||||||
|  |       '{{yq_version_output.stdout.strip() | regex_replace("^.*(\d+\.\d+\.\d+).*$", "\1")}}' | ||||||
|  | 
 | ||||||
|  | - set_fact: | ||||||
|  |     asset: '{{assets | to_json | from_json | json_query(asset_query)}}' | ||||||
|  | 
 | ||||||
|  | - name: download executable | ||||||
|  |   when: installed_version is not defined or installed_version != latest_version | ||||||
|  |   get_url: | ||||||
|  |     url: '{{asset.browser_download_url}}' | ||||||
|  |     dest: '{{yq_exe}}' | ||||||
|  |     mode: +x | ||||||
							
								
								
									
										5
									
								
								roles/yq/tasks/Windows.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								roles/yq/tasks/Windows.yaml
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,5 @@ | |||||||
|  | --- | ||||||
|  | - name: install chocolatey package | ||||||
|  |   win_chocolatey: | ||||||
|  |     name: yq | ||||||
|  |     state: latest | ||||||
							
								
								
									
										2
									
								
								roles/yq/tasks/main.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								roles/yq/tasks/main.yaml
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,2 @@ | |||||||
|  | --- | ||||||
|  | - include_tasks: '{{ansible_os_family}}.yaml' | ||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user