Closed jon-stumpf closed 7 months ago
I am unable to reproduce this issue:
Tested with
---
k3s_cluster:
children:
server:
hosts:
192.168.1.91:
# Required Vars
vars:
ansible_port: 22
ansible_user: pi
k3s_version: v1.26.9+k3s1
token: "mytoken" # Use ansible vault if you want to keep it secret
api_endpoint: "{{ hostvars[groups['server'][0]]['ansible_host'] | default(groups['server'][0]) }}"
extra_server_args: ""
extra_agent_args: ""
Running ansible-playbook -i pi.yml ./playbook/site.yml
, I see the airgap tasks being skipped as designed. (Only change is I removed the [Airgap] on all the task names).
TASK [prereq : Copy manifests] ***********************************************************************************************************************
skipping: [192.168.1.91]
TASK [prereq : Make config directory] ****************************************************************************************************************
skipping: [192.168.1.91]
TASK [prereq : Copy config values] *******************************************************************************************************************
skipping: [192.168.1.91]
TASK [airgap : Download k3s install script] **********************************************************************************************************
skipping: [192.168.1.91]
TASK [airgap : Distribute K3s install script] ********************************************************************************************************
skipping: [192.168.1.91]
TASK [airgap : Distribute K3s binary] ****************************************************************************************************************
skipping: [192.168.1.91]
TASK [airgap : Distribute K3s SELinux RPM] ***********************************************************************************************************
skipping: [192.168.1.91]
TASK [airgap : Install K3s SELinux RPM] **************************************************************************************************************
skipping: [192.168.1.91]
TASK [airgap : Make images directory] ****************************************************************************************************************
skipping: [192.168.1.91]
TASK [airgap : Determine Architecture] ***************************************************************************************************************
skipping: [192.168.1.91]
TASK [airgap : Distribute K3s amd64 images] **********************************************************************************************************
skipping: [192.168.1.91] => (item=/home/derek/rancher/k3s-ansible/roles/airgap/)
skipping: [192.168.1.91]
TASK [airgap : Distribute K3s arm64 images] **********************************************************************************************************
skipping: [192.168.1.91] => (item=/home/derek/rancher/k3s-ansible/roles/airgap/)
skipping: [192.168.1.91]
TASK [airgap : Distribute K3s arm images] ************************************************************************************************************
skipping: [192.168.1.91] => (item=/home/derek/rancher/k3s-ansible/roles/airgap/)
skipping: [192.168.1.91]
TASK [airgap : Run K3s Install [server]] *************************************************************************************************************
skipping: [192.168.1.91]
TASK [airgap : Run K3s Install [agent]] **************************************************************************************************************
skipping: [192.168.1.91]
The skip line at https://github.com/k3s-io/k3s-ansible/blob/master/roles/airgap/tasks/main.yml#L73 is specifically designed to avoid the errors you are receiving, but the without the airgap_dir
because of https://github.com/k3s-io/k3s-ansible/blob/1e8bfb0d3967defe66929616f50a2f40d2470a87/roles/airgap/tasks/main.yml#L3, that entire airgap task should be skipped.
:-| Checking further.
I am at a loss. I have debug statements within the block that are appropriately not executing and it is skipping all previous tasks like your output. However, for some reason, it is evaluating this task. Trying to find the difference.
I am running:
ansible-playbook 2.10.8 config file = \~/turingpi/k3s-ansible-latest/ansible.cfg configured module search path = ['\~/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] ansible python module location = /usr/lib/python3/dist-packages/ansible executable location = /usr/bin/ansible-playbook python version = 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0]
@dereknola , what are you running?
And, the below works. Yet, it should be equivalent.
diff --git a/roles/airgap/tasks/main.yml b/roles/airgap/tasks/main.yml
index 378f61b..32cf7ac 100644
--- a/roles/airgap/tasks/main.yml
+++ b/roles/airgap/tasks/main.yml
@@ -60,13 +60,14 @@
- name: Distribute K3s amd64 images [Airgap]
when: ansible_architecture == 'x86_64'
ansible.builtin.copy:
- src: "{{ item }}"
+ src: "{{ lookup('first_found', params) }}"
dest: /var/lib/rancher/k3s/agent/images/k3s-airgap-images-amd64.tar
owner: root
group: root
mode: 0755
- with_first_found:
- - files:
+ vars:
+ params:
+ files:
- "{{ airgap_dir }}/k3s-airgap-images-amd64.tar.zst"
- "{{ airgap_dir }}/k3s-airgap-images-amd64.tar.gz"
- "{{ airgap_dir }}/k3s-airgap-images-amd64.tar"
My core version is several releases newer, could that be the difference?
ansible-playbook [core 2.15.6]
config file = None
configured module search path = ['/home/derek/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/derek/.local/lib/python3.10/site-packages/ansible
ansible collection location = /home/derek/.ansible/collections:/usr/share/ansible/collections
executable location = /home/derek/.local/bin/ansible-playbook
python version = 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] (/usr/bin/python3)
jinja version = 3.0.3
libyaml = True
I just tried with ansible 2.10.17 and now can see the same error you do. I'll do more testing and see when this gets resolved.
Okay moving up to ansible core 2.12.10 resolved the issue. I think expecting users to have a more modern ansible release (2.12 came out 08 Nov 2021 and is already EOL) is fine. I will update the README accordingly.
ansible 2.10.7 is the version for Ubuntu 22.04.03 LTS. I will update it from another repository. Thanks.
I'm on ansible-playbook [core 2.15.2]
and still encountering this issue :(
TASK [airgap : Determine Architecture] **************************************************************************************************************************************************************************************************
task path: /Users/zen/projects/work/al/infra/k3s-ansible/roles/airgap/tasks/main.yml:62
skipping: [10.0.60.50] => {
"changed": false,
"false_condition": "airgap_dir is defined",
"skip_reason": "Conditional result was False"
}
skipping: [10.0.60.51] => {
"changed": false,
"false_condition": "airgap_dir is defined",
"skip_reason": "Conditional result was False"
}
TASK [airgap : Distribute K3s amd64 images] *********************************************************************************************************************************************************************************************
task path: /Users/zen/projects/work/al/infra/k3s-ansible/roles/airgap/tasks/main.yml:66
fatal: [10.0.60.50]: FAILED! => {
"msg": "No file was found when using first_found."
}
fatal: [10.0.60.51]: FAILED! => {
"msg": "No file was found when using first_found."
}
PLAY RECAP ******************************************************************************************************************************************************************************************************************************
10.0.60.50 : ok=8 changed=0 unreachable=0 failed=1 skipped=28 rescued=0 ignored=0
10.0.60.51 : ok=8 changed=0 unreachable=0 failed=1 skipped=28 rescued=0 ignored=0
❯
❯
k3s_cluster:
children:
server:
hosts:
10.0.60.50:
agent:
hosts:
10.0.60.51:
#10.0.60.52:
# Required Vars
vars:
ansible_ssh_common_args: xxx
ansible_user: ubuntu
k3s_version: v1.28.3+k3s2
token: "xx"
api_endpoint: "{{ hostvars[groups['server'][0]]['ansible_host'] | default(groups['server'][0]) }}"
extra_server_args: ""
extra_agent_args: ""
Bumping ansible to 2.15.6 solved the issue. Very weird.
Same error for me, upgrading to 2.16.2 solved it. Maybe the README should be updated ?
I attempted to create a simple cluster with three nodes. Here is my inventory.yml file.
When running ansible-playbook playbook/site.yml, I get the following errors from role/airgap:
This error will occur at the following locations:
I can add ignore_errors: true to the ansible.builtin.copy tasks to allow the playbook to proceed, but this does not seem the correct thing to do (given the error messages still produced). And, since airgap_dir is not defined in my case, I don't understand why it is in the block to begin with. See https://github.com/k3s-io/k3s-ansible/blob/1e8bfb0d3967defe66929616f50a2f40d2470a87/roles/airgap/tasks/main.yml#L3