This commit is contained in:
2022-10-30 09:53:14 -05:00
parent 45585f33bc
commit cc44f9bb78
4 changed files with 52 additions and 0 deletions

View File

@@ -56,3 +56,12 @@
group: "user" group: "user"
mode: '0770' mode: '0770'
state: directory state: directory
- name: Create credentials folder
become_user: user
ansible.builtin.file:
path: ~/.credentials
owner: "user"
group: "user"
mode: '0700'
state: directory

View File

@@ -20,10 +20,14 @@ required_packages:
- gnome-calculator - gnome-calculator
- gnome-disk-utility - gnome-disk-utility
- gnome-system-monitor - gnome-system-monitor
- nano
- gedit
- code
required_repository: required_repository:
- {baseurl: 'https://packages.microsoft.com/rhel/8/prod/', name: 'Microsoft', gpgkey: 'https://packages.microsoft.com/keys/microsoft.asc'} - {baseurl: 'https://packages.microsoft.com/rhel/8/prod/', name: 'Microsoft', gpgkey: 'https://packages.microsoft.com/keys/microsoft.asc'}
- {baseurl: 'https://packages.microsoft.com/yumrepos/vscode', name: 'Visual Studio Code', gpgkey: 'https://packages.microsoft.com/keys/microsoft.asc'}
- {baseurl: 'https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64/', name: 'Kubernetes', gpgkey: 'https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg'} - {baseurl: 'https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64/', name: 'Kubernetes', gpgkey: 'https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg'}
- {baseurl: 'https://rpm.releases.hashicorp.com/RHEL/8/x86_64/stable/', name: 'Hashicorp', gpgkey: 'https://rpm.releases.hashicorp.com/gpg'} - {baseurl: 'https://rpm.releases.hashicorp.com/RHEL/8/x86_64/stable/', name: 'Hashicorp', gpgkey: 'https://rpm.releases.hashicorp.com/gpg'}

31
scripts/configure-ssh.ps1 Normal file
View File

@@ -0,0 +1,31 @@
if(!(test-path ~/.ssh/id_rsa)){
ssh-keygen -b 2048 -t rsa -f ~/.ssh/id_rsa -q -N '""'
}
#Gitlab set ssh key
if($(Test-Path "~/.credentials/gitlab" )){
TOKEN = Get-Content "~/.credentials/gitlab" | ConvertTo-SecureString-AsPlainText
$header = @{
"PRIVATE-TOKEN"=$TOKEN
}
$GitlabAPI = "https://gitlab.com/api/v4"
$publickey = Get-Content ~/.ssh/id_rsa.pub
$body = @{
title = "Ansible Script"
key = "$publickey"
expires_at ="$((get-date).AddDays(30).ToUniversalTime().ToString("o"))"
} | 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 -notlike "*has already been taken*"){
Write-Error "Failed to upload key"
exit -1
}
}
}

View File

@@ -0,0 +1,8 @@
param(
$service,
$password
)
if($service -eq "gitlab"){
$password | ConvertTo-SecureString -AsPlainText -Force | ConvertFrom-SecureString | Out-File ~/.credentials/gitlab
}