update
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
- hosts: localhost
|
||||
connection: local
|
||||
become: true
|
||||
vars:
|
||||
GITLAB_TOKEN: "{{ lookup('env', 'GITLAB_TOKEN') }}"
|
||||
# vars_prompt:
|
||||
|
||||
roles:
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
- name: install fonts
|
||||
include_tasks: "./scripts/install_fonts.yml"
|
||||
|
||||
- name: generate ssh keys
|
||||
include_tasks: "./scripts/configure_ssh.yml"
|
||||
|
||||
- name: Configure Gitlab SSH
|
||||
become_user: user
|
||||
ansible.builtin.command: pwsh -f ./scripts/configure_gitlab.ps1 "{{ GITLAB_TOKEN }}"
|
||||
|
||||
- name: set gnome config
|
||||
become_user: user
|
||||
dconf:
|
||||
|
||||
@@ -11,6 +11,7 @@ required_packages_brew:
|
||||
- terraform
|
||||
- kubernetes-cli
|
||||
- zsh-autosuggestions
|
||||
- bitwarden-cli
|
||||
|
||||
apt_keys:
|
||||
- https://packages.microsoft.com/keys/microsoft.asc
|
||||
|
||||
32
ansible/scripts/configure_gitlab.ps1
Normal file
32
ansible/scripts/configure_gitlab.ps1
Normal file
@@ -0,0 +1,32 @@
|
||||
param ($GITLAB_TOKEN)
|
||||
if (!$GITLAB_TOKEN){
|
||||
Write-Output "Please unlock Bitwarden"
|
||||
break
|
||||
}
|
||||
|
||||
#Gitlab set ssh key
|
||||
|
||||
$header = @{
|
||||
"PRIVATE-TOKEN"=$GITLAB_TOKEN
|
||||
}
|
||||
$GitlabAPI = "https://gitlab.com/api/v4"
|
||||
|
||||
$publickey = Get-Content ~/.ssh/id_ed25519.pub
|
||||
|
||||
$body = @{
|
||||
title = "Ansible Script"
|
||||
key = "$publickey"
|
||||
} | ConvertTo-Json
|
||||
|
||||
Try{
|
||||
Invoke-RestMethod -Headers $header -Uri $GitlabAPI/user/keys -Body $body -Method Post -ContentType application/json -ErrorVariable gitlabkey | Out-Null
|
||||
}Catch{
|
||||
if($gitlabkey -like "*Token is expired*"){
|
||||
Write-Error "Token Has Expired"
|
||||
exit -1
|
||||
}
|
||||
if($gitlabkey -notlike "*has already been taken*"){
|
||||
Write-Error "Failed to upload key"
|
||||
exit -1
|
||||
}
|
||||
}
|
||||
5
ansible/scripts/configure_ssh.yml
Normal file
5
ansible/scripts/configure_ssh.yml
Normal file
@@ -0,0 +1,5 @@
|
||||
- name: Generate an OpenSSH keypair
|
||||
become_user: user
|
||||
community.crypto.openssh_keypair:
|
||||
path: ~/.ssh/id_ed25519
|
||||
type: ed25519
|
||||
Reference in New Issue
Block a user