Skip to content

Ansible

Ansible #13

Workflow file for this run

name: Ansible
on:
workflow_dispatch:
inputs:
IP_publica:
type: string
description: IP pública de la VM de IBM Cloud
required: true
jobs:
Ansible:
runs-on: self-hosted
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: checks
run: whoami && ls -la
- name: Ensure sudo does not ask for a password
run: echo "defaults !requiretty" | sudo tee -a /etc/sudoers
- name: Install Ansible, curl, docker, kubectl, AZ CLI
run: |
sudo -i apt update -y && sudo apt upgrade -y
sudo -i apt install -y software-properties-common
sudo -i add-apt-repository --update ppa:ansible/ansible
sudo -i apt -y install ansible
sudo -i apt -y install docker.io
sudo -i systemctl start docker
sudo -i systemctl enable docker
sudo -i apt -y install curl
sudo -i curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
sudo -i install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
# - name: Install Ansible, curl, docker, kubectl, AZ CLI
# run: |
# echo "1234" | sudo -S su
# echo "1234" |sudo -S apt update -y && sudo apt upgrade -y
# echo "1234" |sudo -S apt install -y software-properties-common
# echo "1234" |sudo -S add-apt-repository --update ppa:ansible/ansible
# echo "1234" |sudo -S apt -y install ansible
# echo "1234" |sudo -S apt -y install docker.io
# echo "1234" |sudo -S systemctl start docker
# echo "1234" |sudo -S systemctl enable docker
# echo "1234" |sudo -S apt -y install curl
# echo "1234" |sudo -S curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
# echo "1234" | sudo -S install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
- name: Generar inventario de ansible
run: |
cd ansible
touch inventory.ini
echo "[vm]" >> inventory.ini
echo "${{inputs.IP_publica}} ansible_user=alejandroBD ansible_password=${{secrets.ANSIBLE_PASSWORD}} ansible_become=true ansible_become_method=sudo " >> inventory.ini
# - name: Instalar PostgreSQL en la maquina de BBDD
# run: cd ansible && ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i inventory.ini postgre.yml -u alejandroBD
# env:
# PG_USER: ${{ secrets.PG_USER }}
# PG_PASSWORD: ${{secrets.PG_PASSWORD}}
# - name: Hacer backup de la base de datos en la maquina de backups
# run: |
# cd ansible && ansible-playbook -i inventory.ini backup.yml -u alejandro