creados ficheros ansible
This commit is contained in:
parent
70e5e24f38
commit
4acf7872b8
4
Vagrantfile
vendored
4
Vagrantfile
vendored
@ -3,8 +3,8 @@ Vagrant.configure("2") do |config|
|
||||
config.vm.box_check_update = false
|
||||
config.vm.synced_folder ".", "/vagrant", disabled: true
|
||||
config.vm.provider "libvirt" do |v|
|
||||
v.memory = 2048
|
||||
v.cpus = 3
|
||||
v.memory = 4096
|
||||
v.cpus = 4
|
||||
v.driver = "qemu"
|
||||
end
|
||||
config.vm.define "plano-control" do |pcontrol|
|
||||
|
3
ansible/ansible.cfg
Normal file
3
ansible/ansible.cfg
Normal file
@ -0,0 +1,3 @@
|
||||
[defaults]
|
||||
inventory = hosts
|
||||
host_key_checking = False
|
@ -4,15 +4,21 @@ all:
|
||||
hosts:
|
||||
p_nodo:
|
||||
ansible_ssh_host: 192.168.121.234
|
||||
ansible_ssh_user: debian
|
||||
ansible_ssh_private_key_file: ~/.ssh/id_rsa
|
||||
ansible_ssh_user: vagrant
|
||||
ansible_ssh_private_key_file: ../.vagrant/machines/plano-control/libvirt/private_key
|
||||
trabajadores:
|
||||
hosts:
|
||||
nodo1:
|
||||
ansible_ssh_host: 192.168.121.157
|
||||
ansible_ssh_user: debian
|
||||
ansible_ssh_private_key_file: ~/.ssh/id_rsa
|
||||
ansible_ssh_user: vagrant
|
||||
ansible_ssh_private_key_file: ../.vagrant/machines/nodo1/libvirt/private_key
|
||||
nodo2:
|
||||
ansible_ssh_host: 192.168.121.33
|
||||
ansible_ssh_user: debian
|
||||
ansible_ssh_private_key_file: ~/.ssh/id_rsa
|
||||
ansible_ssh_user: vagrant
|
||||
ansible_ssh_private_key_file: ../.vagrant/machines/nodo2/libvirt/private_key
|
||||
|
||||
vars:
|
||||
fichero: "/home/vagrant/k3s.sh"
|
||||
token_k3s: ""
|
||||
token_k3s_base64: ""
|
||||
ip_pcontrol: "10.10.10.10"
|
41
ansible/site.yaml
Normal file
41
ansible/site.yaml
Normal file
@ -0,0 +1,41 @@
|
||||
- hosts: all
|
||||
become: true
|
||||
tasks:
|
||||
- name: Actualizamos el sistema
|
||||
apt: update_cache=yes upgrade=yes
|
||||
- name: instalación de k3s- nos aseguramos de que curl esté instalado
|
||||
apt:
|
||||
pkg:
|
||||
- curl
|
||||
- name: Descargar instalador k3s
|
||||
get_url:
|
||||
url: https://get.k3s.io
|
||||
dest: "{{ fichero }}"
|
||||
- name: Dar permisos de ejecución al instalador k3s
|
||||
file:
|
||||
path: "{{ fichero }}"
|
||||
mode: '0755'
|
||||
- name: Ejecutar instalador k3s
|
||||
shell: "{{ fichero }}"
|
||||
- name: Borrar instalador k3s
|
||||
file:
|
||||
path: "{{ fichero }}"
|
||||
state: absent
|
||||
|
||||
- hosts: planos_control
|
||||
become: true
|
||||
tasks:
|
||||
- name: sacar token
|
||||
ansible.builtin.slurp:
|
||||
src: "/var/lib/rancher/k3s/server/node-token"
|
||||
register: token_k3s_base64
|
||||
- name: descodificar token
|
||||
ansible.builtin.set_fact:
|
||||
token_k3s: "{{ token_k3s_base64.content | ansible.builtin.b64decode | replace('\n', '' ) }}"
|
||||
- debug: msg="el token es {{token_k3s}}"
|
||||
|
||||
- hosts: trabajadores
|
||||
become: true
|
||||
tasks:
|
||||
- name: Ejecutar instalador k3s
|
||||
shell: "k3s agent --server https://{{ ip_pcontrol }}:6443 --token {{ token_k3s }}"
|
Loading…
x
Reference in New Issue
Block a user