Try ansible config file #7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Configure Kubernetes Master Node | |
on: | |
push: | |
branches: | |
- develop | |
- main | |
pull_request: | |
branches: | |
- develop | |
- main | |
jobs: | |
configure-master: | |
runs-on: ubuntu-latest | |
steps: | |
# Schritt 1: Repository auschecken | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
# Schritt 2: Installiere Ansible | |
- name: Install Ansible | |
run: | | |
sudo apt update | |
sudo apt install -y ansible | |
# Schritt 3: Setup SSH Key | |
- name: Setup SSH key | |
run: | | |
mkdir -p ~/.ssh | |
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa | |
chmod 600 ~/.ssh/id_rsa | |
shell: bash | |
# Schritt 4: Füge die Master-Node zur known_hosts-Datei hinzu | |
- name: Add server to known hosts | |
run: | | |
echo "Adding server ${{ vars.MASTER_NODE_IP }} to the known hosts" | |
ssh-keyscan -H ${{ vars.MASTER_NODE_IP }} >> ~/.ssh/known_hosts | |
# Schritt 5: Führe das Ansible-Playbook aus | |
- name: Run Ansible Playbook | |
working-directory: ops/ansible | |
run: | | |
ansible-playbook -i ${{ vars.MASTER_NODE_IP }}, -u ${{ vars.MASTER_NODE_USER }} playbooks/master-setup.yml |