Delete Servers & Workflows/Linux/Automation/Puppet/Storing Puppets in Gitea.md

This commit is contained in:
2024-10-03 19:02:12 -06:00
parent 5227411097
commit b0349c5f12

View File

@ -1,67 +0,0 @@
**Purpose**:
At this point, we need to configure Gitea as the storage repository for the Puppet "Environments" (e.g. `Production` and `Development`). We can do this by leveraging a tool called "r10k" which pulls a Git repository and configures it as the environment in Puppet.
## Install r10k
``` sh
# Install r10k Pre-Requisites
sudo dnf install -y ruby ruby-devel gcc make
# Install r10k Gem (The Software)
# Note: If you encounter any issues with permissions, you can install the gem with "sudo gem install r10k --no-document".
sudo gem install r10k
# Verify the Installation (Run this as a non-root user)
r10k version
```
## Configure r10k
``` sh
# Create the r10k Configuration Directory
sudo mkdir -p /etc/puppetlabs/r10k
# Create the r10k Configuration File
sudo nano /etc/puppetlabs/r10k/r10k.yaml
```
```yaml title="/etc/puppetlabs/r10k/r10k.yaml"
---
# Cache directory for r10k
cachedir: '/var/cache/r10k'
# Sources define which repositories contain environments (Be sure to use the SSH URL, not the Git URL)
sources:
puppet:
remote: 'git@git.bunny-lab.io:GitOps/Puppet.git'
basedir: '/etc/puppetlabs/code/environments'
```
``` sh
# Create r10k Cache Directory
sudo mkdir -p /var/cache/r10k
sudo chown -R puppet:puppet /var/cache/r10k
```
## Configure Gitea
At this point, we need to set up the branches and file/folder structure of the Puppet repository on Gitea.
!!! warning "Incomplete"
This section needs a copy of all of the folder structure explained, as well as the branch structure, and example files for things like `site.pp`, `environment.conf`, and `init.pp`. That will be added at a later time soon.
## Exchanging SSH Keys with Gitea
We need to be able to pull down the data from Gitea's Puppet repository under the root user so that r10k can automatically pull down any changes made to the Puppet environments (e.g. `Production` and `Development`). Each Git branch represents a different Puppet environment. We don't want to store credentials in plaintext or in some vulnerable way that might affect the environment. To do this, we will exchange a public key with Gitea.
``` sh
# Generate an SSH Keypair
ssh-keygen -t rsa -b 4096 -C "root@lab-puppet-01.bunny-lab.io"
# Correct any Potential Permission Issues
chmod 700 /root/.ssh
chmod 600 /root/.ssh/id_rsa
chmod 644 /root/.ssh/id_rsa.pub
# Copy the Public Key to the Clipboard
cat /root/.ssh/id_rsa.pub
```
Navigate to "**Gitea > User (Top-Right) > Settings > SSH/GPG Keys > SSH Keys > Add Key**"
- Key Name: `root@lab-puppet-01.bunny-lab.io`
- Content: `<Paste the Clipboard of the Public Key>
- Click the "**Add Key**" button to finish.