vm broker ansible sample ‐ minio multinode multiserver cluster - allanrogerr/public GitHub Wiki

Create and ansible instance

Create an instance to run ansible e.g. ansible-allan. Connect to it.

ssh -p 20089 [email protected] -o "ServerAliveInterval=5" -o "ServerAliveCountMax=100000" -o "StrictHostKeyChecking=off"

Generate keys

On ansible-allan, generate ssh public cert and private key

ssh-keygen -f ~/.ssh/id-ecdsa -t ecdsa -b 521 -P ""

Install ansible

On ansible-allan, install ansible

sudo apt update
sudo apt install software-properties-common -y
sudo add-apt-repository --yes --update ppa:ansible/ansible
sudo apt install ansible -y

Save the ansible public key

Extract the public key and store on your local machine as e.g. ansible-demo.pub. This will subsequently be added to the other machines to allow ansible to access them.

cat ~/.ssh/id-ecdsa.pub 

Create child instances

On your local machine, and using vm-broker (https://vm.k1.min.dev/instances/) spin up several instances on the same node. While creating them, grant them each the public key of the ansible instance. image image

Generate Ansible Hosts

Once ready, select them and hit Generate Ansible Hosts. In the resulting prompt, input the private key path provided from the previous step. e.g. /home/ubuntu/.ssh/id-ecdsa

Create ansible config yml

On your ansible instance, create an ansible config yml, using the ansible output from the previous step

cat << EOF > config.yml
webservers:
  hosts:
    minio-demo0.minio.training:
      ansible_host: 1.2.3.4
      ansible_port: 20008
      ansible_connection: ssh
      ansible_user: ubuntu
      ansible_ssh_user: ubuntu
      ansible_ssh_private_key_file: /home/ubuntu/.ssh/id-ecdsa
    minio-demo1.minio.training:
      ansible_host: 1.2.3.4
      ansible_port: 20030
      ansible_connection: ssh
      ansible_user: ubuntu
      ansible_ssh_user: ubuntu
      ansible_ssh_private_key_file: /home/ubuntu/.ssh/id-ecdsa
    minio-demo2.minio.training:
      ansible_host: 1.2.3.4
      ansible_port: 20003
      ansible_connection: ssh
      ansible_user: ubuntu
      ansible_ssh_user: ubuntu
      ansible_ssh_private_key_file: /home/ubuntu/.ssh/id-ecdsa
    minio-demo3.minio.training:
      ansible_host: 1.2.3.4
      ansible_port: 20032
      ansible_connection: ssh
      ansible_user: ubuntu
      ansible_ssh_user: ubuntu
      ansible_ssh_private_key_file: /home/ubuntu/.ssh/id-ecdsa
  vars:
    # General User variables
    user: ubuntu
    host_list: minio-demo0.minio.training,minio-demo1.minio.training,minio-demo2.minio.training,minio-demo3.minio.training
    minio_repo: https://github.com/allanrogerr/minio.git
    minio_branch: check-is-lxc_test
    host_prefix: minio-demo
    host_count: 4
    host_domain: minio.training
    schema: http
EOF

Clone

Clone own repo with ansible scripts. Use mine as a template.

git clone https://github.com/allanrogerr/ansible-scripts.git

Run Ansible

ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i config.yml -l webservers ~/ansible-scripts/ansible/main.yml

Expected output

PLAY RECAP ***********************************************************************************************************************************************************************************
minio-demo0.minio.training : ok=8    changed=5    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
minio-demo1.minio.training : ok=8    changed=5    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
minio-demo2.minio.training : ok=8    changed=5    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
minio-demo3.minio.training : ok=8    changed=5    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0 

Access

Access cluster at http://minio-demo0.minio.training:10090/

Test

Create a bucket and upload object image

Observe

Observe objects also exist on http://minio-demo{0...3}.minio.training:10090/ image

⚠️ **GitHub.com Fallback** ⚠️