Похожие чаты

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 ответов

10 просмотров

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.

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

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

А еще в перле можно уже @arr1 + @arr2?
Sergei Zhmylove
53
я не магистр хаскеля, но разве не может лейзи тип конвертнуться в не-лейзи запросив вычисление содержимого прям при инициализации?
deadgnom32 λ madao
100
I arrived here after a Chico Crypto show highlighted the project & the Team - the fact that the Team had a long history of successfully working with household names gave me e...
Banter is Bullish
1
Привет всем. появился вопрос. Разрабатываю сайт, в данный момент он запущен. Хостинг beget. Добавляю на сайт яндекс метрику с помощью полей client-settings (взято отсюда http...
Andrew
2
Подскажите, где смотреть результат выполнения программы? Код: ;.686 ;Система команд процессора 686 ;.MODEL FLAT,stdcall ;Модель памяти плоская, станда...
Егор Анелькин
5
Где в Астане можно купить мясо для шашлыков?
Dancing Іңұқәһүғө
21
Lers say somehow tor got shut down What then?
Mark Keller
16
Добрый день подскажите пожалуйста может кто то сталкивался с ошибками Sentry 22.10.0 развернутым из helm чарт в Kubernetes? Изначально 3 дня назад очень стало много событий ух...
Tire4 Finist Devops
1
Ну чё, сегодня все в гавно?))
ᅠ🚀
20
;.686 ;Система команд процессора 686 ;.MODEL FLAT,stdcall ;Модель памяти плоская, стандартный ;вызов процедуры ;option casemap:no...
Егор Анелькин
1
Карта сайта