Add optional GitHub API authentication headers
If the `GITHUB_TOKEN` is defined in the Ansible controller's environment it is used to set the GitHub REST API authentication header. This is they passed to all `uri` modules tasks which interact with the GitHub REST API. If the `GITHUB_TOKEN` is not set, the authentication header is not used. Fixes #19
This commit is contained in:
		
							parent
							
								
									883fee21b3
								
							
						
					
					
						commit
						e711b9f3b2
					
				| @ -2,6 +2,10 @@ | ||||
| - import_playbook: LinuxCLI.yaml | ||||
| - import_playbook: UnixGUI.yaml | ||||
| - hosts: localhost | ||||
|   vars: | ||||
|     github_auth_headers: >- | ||||
|       {{ { 'Authorization': 'Bearer ' + lookup('env', 'GITHUB_TOKEN') } | ||||
|           if lookup('env', 'GITHUB_TOKEN') else {} }} | ||||
|   roles: | ||||
|     - role: firefox | ||||
|     - role: kitty | ||||
|  | ||||
| @ -1,5 +1,9 @@ | ||||
| --- | ||||
| - hosts: localhost | ||||
|   vars: | ||||
|     github_auth_headers: >- | ||||
|       {{ { 'Authorization': 'Bearer ' + lookup('env', 'GITHUB_TOKEN') } | ||||
|           if lookup('env', 'GITHUB_TOKEN') else {} }} | ||||
|   roles: | ||||
|     - role: rpmfusion | ||||
|       when: ansible_os_family == 'RedHat' and ansible_distribution == 'Fedora' | ||||
|  | ||||
| @ -1,5 +1,9 @@ | ||||
| --- | ||||
| - hosts: localhost | ||||
|   vars: | ||||
|     github_auth_headers: >- | ||||
|       {{ { 'Authorization': 'Bearer ' + lookup('env', 'GITHUB_TOKEN') } | ||||
|           if lookup('env', 'GITHUB_TOKEN') else {} }} | ||||
|   roles: | ||||
|     - role: sudo | ||||
|       when: ansible_user_id != "root" | ||||
|  | ||||
| @ -1,5 +1,9 @@ | ||||
| --- | ||||
| - hosts: localhost | ||||
|   vars: | ||||
|     github_auth_headers: >- | ||||
|       {{ { 'Authorization': 'Bearer ' + lookup('env', 'GITHUB_TOKEN') } | ||||
|           if lookup('env', 'GITHUB_TOKEN') else {} }} | ||||
|   roles: | ||||
|     - role: flatpak | ||||
|       when: ansible_os_family != "Darwin" | ||||
|  | ||||
| @ -1,5 +1,9 @@ | ||||
| --- | ||||
| - import_playbook: LinuxCLI.yaml | ||||
| - hosts: localhost | ||||
|   vars: | ||||
|     github_auth_headers: >- | ||||
|       {{ { 'Authorization': 'Bearer ' + lookup('env', 'GITHUB_TOKEN') } | ||||
|           if lookup('env', 'GITHUB_TOKEN') else {} }} | ||||
|   roles: | ||||
|     - role: wsl | ||||
|  | ||||
| @ -1,6 +1,9 @@ | ||||
| --- | ||||
| - hosts: windows | ||||
| 
 | ||||
|   vars: | ||||
|     github_auth_headers: >- | ||||
|       {{ { 'Authorization': 'Bearer ' + lookup('env', 'GITHUB_TOKEN') } | ||||
|           if lookup('env', 'GITHUB_TOKEN') else {} }} | ||||
|   roles: | ||||
|     - role: python | ||||
|     - role: git | ||||
|  | ||||
| @ -5,6 +5,10 @@ | ||||
|     - role: system-info | ||||
| - import_playbook: UnixGUI.yaml | ||||
| - hosts: localhost | ||||
|   vars: | ||||
|     github_auth_headers: >- | ||||
|       {{ { 'Authorization': 'Bearer ' + lookup('env', 'GITHUB_TOKEN') } | ||||
|           if lookup('env', 'GITHUB_TOKEN') else {} }} | ||||
|   roles: | ||||
|     - role: mas | ||||
| 
 | ||||
|  | ||||
| @ -2,6 +2,7 @@ | ||||
| - name: get latest github release | ||||
|   uri: | ||||
|     url: https://api.github.com/repos/sharkdp/bat/releases/latest | ||||
|     headers: '{{github_auth_headers}}' | ||||
|   register: latest | ||||
| 
 | ||||
| - set_fact: | ||||
|  | ||||
| @ -17,6 +17,7 @@ | ||||
| - name: get latest release | ||||
|   uri: | ||||
|     url: https://api.github.com/repos/ryanoasis/nerd-fonts/releases/latest | ||||
|     headers: '{{github_auth_headers}}' | ||||
|   register: latest | ||||
| 
 | ||||
| - set_fact: | ||||
|  | ||||
| @ -2,6 +2,7 @@ | ||||
| - name: get json containing all releases | ||||
|   win_uri: | ||||
|     url: 'https://api.github.com/repos/git-for-windows/git/releases/tags/v{{git_version}}.windows.1' | ||||
|     headers: '{{github_auth_headers}}' | ||||
|     return_content: true | ||||
|   register: git_release | ||||
| 
 | ||||
|  | ||||
| @ -2,6 +2,7 @@ | ||||
| - name: get latest github release | ||||
|   uri: | ||||
|     url: https://api.github.com/repos/jmespath/jp/releases/latest | ||||
|     headers: '{{github_auth_headers}}' | ||||
|   register: latest | ||||
| 
 | ||||
| - set_fact: | ||||
|  | ||||
| @ -19,6 +19,7 @@ | ||||
| - name: get latest release | ||||
|   uri: | ||||
|     url: 'https://api.github.com/repos/jmespath/jp/releases/latest' | ||||
|     headers: '{{github_auth_headers}}' | ||||
|   register: latest | ||||
| 
 | ||||
| - name: determine if jp needs installed | ||||
|  | ||||
| @ -2,6 +2,7 @@ | ||||
| - name: get latest stable github release | ||||
|   uri: | ||||
|     url: https://api.github.com/repos/llvm/llvm-project/releases/latest | ||||
|     headers: '{{github_auth_headers}}' | ||||
|   register: llvm_latest | ||||
| 
 | ||||
| - name: read /etc/os-release | ||||
|  | ||||
| @ -40,6 +40,7 @@ | ||||
| - name: get latest version | ||||
|   uri: | ||||
|     url: https://api.github.com/repos/neovim/neovim/releases/latest | ||||
|     headers: '{{github_auth_headers}}' | ||||
|   register: latest | ||||
| 
 | ||||
| - set_fact: | ||||
|  | ||||
| @ -30,6 +30,7 @@ | ||||
| - name: get latest release | ||||
|   uri: | ||||
|     url: https://api.github.com/repos/k0kubun/xremap/releases/latest | ||||
|     headers: '{{github_auth_headers}}' | ||||
|   register: latest | ||||
| 
 | ||||
| - name: determine if install needed | ||||
|  | ||||
| @ -2,6 +2,7 @@ | ||||
| - name: get latest github release | ||||
|   uri: | ||||
|     url: https://api.github.com/repos/mikefarah/yq/releases/latest | ||||
|     headers: '{{github_auth_headers}}' | ||||
|   register: latest | ||||
| 
 | ||||
| - set_fact: | ||||
|  | ||||
| @ -19,6 +19,7 @@ | ||||
| - name: get latest release | ||||
|   uri: | ||||
|     url: 'https://api.github.com/repos/mikefarah/yq/releases/latest' | ||||
|     headers: '{{github_auth_headers}}' | ||||
|   register: latest | ||||
| 
 | ||||
| - name: determine if yq needs installed | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user