Похожие чаты

Guys I have an Ansible for activating a k8s master: -

name: Activate Master node
hosts: all
tasks:
- name: Export2
shell: kubectl version | base64 | tr -d '\n'
register: output
#become: yes
- name: Exec all
shell: kubectl apply -f "https://cloud.weave.works/k8s/net?k8s-version={{ output.stdout }}"
~
I will execute this as root. but the last command will not execute with an error like this:
fatal: [185.255.91.121]: FAILED! => {"changed": true, "cmd": "kubectl apply -f \"https://cloud.weave.works/k8s/net?k8s-version=Q2xpZW50IFZlcnNpb246IHZlcnNpb24uSW5mb3tNYWpvcjoiMSIsIE1pbm9yOiIyMiIsIEdpdFZlcnNpb246InYxLjIyLjAiLCBHaXRDb21taXQ6ImMyYjUyMzdjY2Q5YzBmMWQ2MDBkMzA3MjYzNGNhNjZjZWZkZjI3MmYiLCBHaXRUcmVlU3RhdGU6ImNsZWFuIiwgQnVpbGREYXRlOiIyMDIxLTA4LTA0VDE4OjAzOjIwWiIsIEdvVmVyc2lvbjoiZ28xLjE2LjYiLCBDb21waWxlcjoiZ2MiLCBQbGF0Zm9ybToibGludXgvYW1kNjQifQo=\"", "delta": "0:00:00.077468", "end": "2021-08-08 07:17:20.846559", "msg": "non-zero return code", "rc": 1, "start": "2021-08-08 07:17:20.769091", "stderr": "The connection to the server localhost:8080 was refused - did you specify the right host or port?", "stderr_lines": ["The connection to the server localhost:8080 was refused - did you specify the right host or port?"], "stdout": "", "stdout_lines": []}
But I can execute it manually on the target server. what can be the reason?

17 ответов

31 просмотр

Read the error message

Ehsan- Автор вопроса
Raptor Blue Bear
Read the error message

I've read that error message, but the same command will execute manually What should be the reason?

Ehsan- Автор вопроса
Sharuzzaman Ahmat Raslan
Using which user when it works?

and I run playbook using -i root@myserver

Ehsan- Автор вопроса
Ehsan
Is there any clue?

Yes, your kubeconfig is not being picked up. Hence the localhost:8080 (the unconfigured default)

Ehsan- Автор вопроса
Raptor Blue Bear
Yes, your kubeconfig is not being picked up. Hence...

So why that command executes on target server manually?

Ehsan- Автор вопроса
Ehsan
screenshot

Check your environment variables. Probably kubeconfig is setup for login shell but not for your ansible

Ehsan
screenshot Same command through Ansible

Same thing applies. When the command runs as the Ansible user it is not using the kubeconfig. Fix that

Ehsan- Автор вопроса
Sathya Bhat
Check your environment variables. Probably kubecon...

Thats it, my playbook can not recognize KUBECONFIG inside .bashrc

Ehsan
Thats it, my playbook can not recognize KUBECONFIG...

That's because ansible isn't really doing things through the shell, it's transferring modules and executing scripts that it transfers, not using a login shell.

Ehsan- Автор вопроса

define KUBECONFIG environment variable in your playbook.

Похожие вопросы

Обсуждают сегодня

Господа, а что сейчас вообще с рынком труда на делфи происходит? Какова ситуация?
Rꙮman Yankꙮvsky
29
А вообще, что может смущать в самой Julia - бы сказал, что нет единого стандартного подхода по многим моментам, поэтому многое выглядит как "хаки" и произвол. Короче говоря, с...
Viktor G.
2
@Benzenoid can you tell me the easiest, and safest way to bu.y HEX now?
Živa Žena
20
This is a question from my wife who make a fortune with memes 😂😂 About the Migration and Tokens: 1. How will the old tokens be migrated to the new $LGCYX network? What is th...
🍿 °anton°
2
30500 за редактор? )
Владимир
47
а через ESC-код ?
Alexey Kulakov
29
What is the Dex situation? Agora team started with the Pnetwork for their dex which helped them both with integration. It’s completed but as you can see from the Pnetwork ann...
Ben
1
Гайс, вопрос для разносторонее развитых: читаю стрим с юарта, нада выделять с него фреймы с определенной структурой, если ли чо готовое, или долбаться с ринг буффером? нада у...
Vitaly
9
Anyone knows where there are some instructions or discort about failed bridge transactions ?
Jochem
21
@lozuk how do I get my phex copies of my ehex from a atomic wallet, to move to my rabby?
Justfrontin 👀
11
Карта сайта