diff --git a/roles/customize/tasks/defaults.yml b/roles/customize/tasks/defaults.yml index 2f71e2f..72ffb71 100644 --- a/roles/customize/tasks/defaults.yml +++ b/roles/customize/tasks/defaults.yml @@ -56,3 +56,12 @@ group: "user" mode: '0770' state: directory + +- name: Create credentials folder + become_user: user + ansible.builtin.file: + path: ~/.credentials + owner: "user" + group: "user" + mode: '0700' + state: directory \ No newline at end of file diff --git a/roles/packages/vars/Fedora-36.yml b/roles/packages/vars/Fedora-36.yml index 07e4bb5..e40a068 100644 --- a/roles/packages/vars/Fedora-36.yml +++ b/roles/packages/vars/Fedora-36.yml @@ -20,10 +20,14 @@ required_packages: - gnome-calculator - gnome-disk-utility - gnome-system-monitor + - nano + - gedit + - code 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/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://rpm.releases.hashicorp.com/RHEL/8/x86_64/stable/', name: 'Hashicorp', gpgkey: 'https://rpm.releases.hashicorp.com/gpg'} diff --git a/scripts/configure-ssh.ps1 b/scripts/configure-ssh.ps1 new file mode 100644 index 0000000..8294603 --- /dev/null +++ b/scripts/configure-ssh.ps1 @@ -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 + } + } +} \ No newline at end of file diff --git a/scripts/credential-file.ps1 b/scripts/credential-file.ps1 new file mode 100644 index 0000000..b50a0bb --- /dev/null +++ b/scripts/credential-file.ps1 @@ -0,0 +1,8 @@ +param( + $service, + $password +) + +if($service -eq "gitlab"){ + $password | ConvertTo-SecureString -AsPlainText -Force | ConvertFrom-SecureString | Out-File ~/.credentials/gitlab +} \ No newline at end of file