update: add network configuration variables and enhance Ansible playbooks for dynamic IP handling
This commit is contained in:
parent
eba7f8322d
commit
ae59661982
6 changed files with 68 additions and 31 deletions
|
|
@ -4,6 +4,8 @@
|
|||
connection: local
|
||||
become: true
|
||||
become_user: root
|
||||
vars_files:
|
||||
- vars.yaml
|
||||
|
||||
tasks:
|
||||
- name: Ensure .kube directory exists
|
||||
|
|
@ -17,7 +19,7 @@
|
|||
- name: Copy kubeconfig using scp directly
|
||||
ansible.builtin.command: >
|
||||
scp -i ~/.ssh/vm1_key -o StrictHostKeyChecking=no
|
||||
vagrant@192.168.56.80:/home/vagrant/.kube/config
|
||||
vagrant@{{ vm1_ip }}:/home/vagrant/.kube/config
|
||||
/home/vagrant/.kube/config
|
||||
become: false
|
||||
|
||||
|
|
@ -32,7 +34,7 @@
|
|||
- name: copy k3s binary to /usr/local/bin/k3s
|
||||
ansible.builtin.command: >
|
||||
scp -i ~/.ssh/vm1_key -o StrictHostKeyChecking=no
|
||||
vagrant@192.168.56.80:/usr/local/bin/k3s
|
||||
vagrant@{{ vm1_ip }}:/usr/local/bin/k3s
|
||||
/usr/local/bin/k3s
|
||||
become: true
|
||||
|
||||
|
|
@ -63,8 +65,8 @@
|
|||
group: vagrant
|
||||
mode: "0644"
|
||||
|
||||
- name: replace 127.0.0.1:6443 192.168.56.80:6443 in .kube/config
|
||||
- name: replace 127.0.0.1:6443 with {{ vm1_ip }}:6443 in .kube/config
|
||||
ansible.builtin.replace:
|
||||
path: /home/vagrant/.kube/config
|
||||
regexp: "127.0.0.1:6443"
|
||||
replace: "192.168.56.80:6443"
|
||||
replace: "{{ vm1_ip }}:6443"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue