Al
хотя я уже х.з. :)
Al
Ну дак по этой ссылке тоже самое написано:)
простите, но не могу вкурить.
Файл в папку и файл создал.
.
├── lamp.yml
└── roles
└── lamp
├── collections
│   └── requirements.yml
├── handlers
│   └── main.yml
├── main.yml
├── tasks
requirements.yml:
---
collections:
- name: community.general
но что-то не выходит каменный цветок:(
да, это я
до чего ансиболь людей доводит.
64D
Просто сейчас какая то дичь с нло начинается🤡
BB
что за магия?
выполняю плей:
"""
---
- name: Play bt
hosts: workers
gather_facts: no
roles:
- { role: update/workers }
"""
инвентарий:
"""
[workers]
172.16.231.130
"""
почему-то все команды выполняет на локалхосте, несмотря на то, что в выводе показывает, что работает происходит в группе workers:
PLAY RECAP *************************************************************************************************************************************************
172.16.231.130 : ok=2 changed=1 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
BB
как это понял:
в роли выполнил task с ls /home и увидел, что отображаются юзера с локалхоста
Дмитрий
BB
ansible-playbook -vvv -i hosts workers.p.yaml
BB
ls с 172.16.231.130:
# ls /home/
nomailuser user
ls c localhost:
$ ls /home/
polemarch user
play:
"invocation": {
"module_args": {
"_raw_params": "ls /home",
"_uses_shell": false,
"argv": null,
"chdir": null,
"creates": null,
"executable": null,
"removes": null,
"stdin": null,
"stdin_add_newline": true,
"strip_empty_ends": true,
"warn": false
}
},
"rc": 0,
"start": "2023-04-25 20:57:42.618790"
}
STDOUT:
polemarch
user
BB
структура, если это как-то поможет в поиске ответа:
...
├── roles/
│ |
│ ├── update/
| | |
| | ├── workers/
| | | |
| | | ├── tasks/
| | | | |
| | | | ├── main.yml
| ...
├── workers.p.yaml
├── hosts
BB
gpt все валит на ssh)))
If Ansible is showing the proper host in the output but executing commands locally, it may be due to the fact that you have not properly configured SSH access to the target host.
Make sure that you have added the target host's SSH key to your local machine's authorized_keys file. You can do this by copying the contents of the target host's public key (usually located in /home/[user]/.ssh/id_rsa.pub) and appending it to your local machine's authorized_keys file (usually located in /home/[user]/.ssh/authorized_keys).
Once you have added the target host's SSH key to your local machine, try running the playbook again and see if it executes commands on the target host instead of locally.
Sergey
BB
Sergey
Да
Sergey
О, ещё .ssh/config надо проверить
dslimp
Zangar
GithubReleases
ansible/ansible tagged: v2.15.0rc1
Link: https://github.com/ansible/ansible/releases/tag/v2.15.0rc1
Release notes:
# Changelog
See the [full changelog](https://github.com/ansible/ansible/blob/v2.15.0rc1/changelogs/CHANGELOG-v2.15.rst) for the changes included in this release.
# Release Artifacts
* 9d40ecdd616726319502c4dd35669cab7b602b2279be12d1e51096165e904...
More
Vladimir
P9oS
mysqld_exporter_config_file: "mysqld_exporter.cnf"
# mysqld_exporter_host: localhost
# mysqld_exporter_port: 3306
mysqld_exporter_socket: "/run/mysqld/mysqld.sock"
В коллекции есть подобные переменные возможно, как нибудь сбросить mysqld_exporter_socket, при этом не залезая в сам код роли?
Alexander
Всем привет!
Есть у кого опыт использования AWX ?
создаю креды с типом HashiCorp Vault Secret Lookup - успешно их тестирую через вебку
Но когда пытаюсь их добавить в темлпйт джобы - не удается(не дают даже выбрать их)
может у кого было?
dReaM
забавно, да, такого пункта нет в кредах
dReaM
Значит как-то по другому используется
Mikhail
Mikhail
Alexander
Mikhail
Alexander
суть такая
Есть роль,которая обновляет сертификаты на хостах
серты хранятся в вольте
локально когда запускаю роль,то авторизуюсь в вольте типа так
export VAULT_ADDR=https://vault.prod.ritm.site
VAULT_ADDR=https://vault.prod.ritm.site ;vault login -method=ldap username=test
и роль из вольта достает серты
мне нужно настроить AWX таким образом,чтобы он тоже мог в вольт ходить
Alexander
как я это видел - создатся креденшнл с типом HashiCorp Vault Secret Lookup
их подсасывает джоба и ходит спокойно в вольт
Alexander
а тут видимо другая логика
из вольта дает подтянуть какое-то конкретное поле
Логин юзера скажем или пасс
Rustam
Здравствуйте
Rustam
Я только начать изучать ansible, можете подсказать как подключаться к коммутаторам, например к edge-core?
Я могу подключиться по ssh, но если отправить пинг, то появляется ошибка "permission denied"
Vened
А можно каким-то образом при прогоне плэйбука отключить вывод финальной секции PLAY RECAP?
Denis 災 nobody
Timur
Vened
Rustam
Aleksandr
Ansible На Русском Языке
https://www.youtube.com/playlist?list=PLg5SS_4L6LYufspdPupdynbMQTBnZd31N
Aleksandr
Sergei
BB
уже не знаю, куда еще смотреть ...
проверил /etc/hosts/ + ssh конфиги, но все равно работает аномально ansible:
172.16.231.131 | SUCCESS => {
"changed": false,
"ping": "pong"
}
$ ping 172.16.231.131
PING 172.16.231.131 (172.16.231.131) 56(84) bytes of data.
From 172.16.231.1 icmp_seq=1 Destination Host Unreachable
Lamobot
Lamobot
А ансибл не через пинг проверяет доступность хостов.
Lamobot
И на хосте просто заблокированы пинги
BB
а есть какой-то способ увидеть, на какой реально хост стучится ансибл?
то, что здесь написан нужный ip - видимо не сильно похоже на правду))
Кирилл
BB
Такое может быть если на хосте закрыт icmp
Добавь ключ -vvv при выполнении плейбука
ansible [core 2.13.8]
config file = /etc/ansible/ansible.cfg
configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/user/.local/lib/python3.8/site-packages/ansible
ansible collection location = /home/user/.ansible/collections:/usr/share/ansible/collections
executable location = /home/user/.local/bin/ansible
python version = 3.8.10 (default, Mar 13 2023, 10:26:41) [GCC 9.4.0]
jinja version = 3.1.2
libyaml = True
Using /etc/ansible/ansible.cfg as config file
host_list declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
script declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
auto declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
Parsed /etc/ansible/hosts inventory source with ini plugin
Skipping callback 'default', as we already have a stdout callback.
Skipping callback 'minimal', as we already have a stdout callback.
Skipping callback 'oneline', as we already have a stdout callback.
META: ran handlers
redirecting (type: connection) ansible.builtin.network_cli to ansible.netcommon.network_cli
redirecting (type: terminal) ansible.builtin.ios to cisco.ios.ios
redirecting (type: cliconf) ansible.builtin.ios to cisco.ios.ios
<172.16.231.131> ESTABLISH LOCAL CONNECTION FOR USER: user
<172.16.231.131> EXEC /bin/sh -c '( umask 77 && mkdir -p " echo /home/user/.ansible/tmp/ansible-local-12177debnqk0p "&& mkdir " echo /home/user/.ansible/tmp/ansible-local-12177debnqk0p/ansible-tmp-1682616606.446469-12181-109006093159165 " && echo ansible-tmp-1682616606.446469-12181-109006093159165=" echo /home/user/.ansible/tmp/ansible-local-12177debnqk0p/ansible-tmp-1682616606.446469-12181-109006093159165 " ) && sleep 0'
Using module file /home/user/.local/lib/python3.8/site-packages/ansible/modules/ping.py
<172.16.231.131> PUT /home/user/.ansible/tmp/ansible-local-12177debnqk0p/tmpils4hw5y TO /home/user/.ansible/tmp/ansible-local-12177debnqk0p/ansible-tmp-1682616606.446469-12181-109006093159165/AnsiballZ_ping.py
<172.16.231.131> EXEC /bin/sh -c 'chmod u+x /home/user/.ansible/tmp/ansible-local-12177debnqk0p/ansible-tmp-1682616606.446469-12181-109006093159165/ /home/user/.ansible/tmp/ansible-local-12177debnqk0p/ansible-tmp-1682616606.446469-12181-109006093159165/AnsiballZ_ping.py && sleep 0'
<172.16.231.131> EXEC /bin/sh -c '/usr/bin/python3 /home/user/.ansible/tmp/ansible-local-12177debnqk0p/ansible-tmp-1682616606.446469-12181-109006093159165/AnsiballZ_ping.py && sleep 0'
<172.16.231.131> EXEC /bin/sh -c 'rm -f -r /home/user/.ansible/tmp/ansible-local-12177debnqk0p/ansible-tmp-1682616606.446469-12181-109006093159165/ > /dev/null 2>&1 && sleep 0'
172.16.231.131 | SUCCESS => {
"changed": false,
"invocation": {
"module_args": {
"data": "pong"
}
},
"ping": "pong"
}
META: ran handlers
BB
вроде ничего не увидел такого
Кирилл
BB
А в чем у тебя проблема то?
любые команды выполняются на локальном хосте вместо удаленных, несмотря на то, что в debug отображаются удаленные
BB
BB
- name: test
hosts: workers
gather_facts: no
tasks:
- name: LS command
command: "ls /home"
register: dir_out
- debug: var={{item}}
with_items: dir_out.stdout_lines
BB
hosts:
"""
[workers]
172.16.231.130 ansible_user=root ansible_ssh_pass=**
"""
BB
ok: [172.16.231.130] => (item=dir_out.stdout_lines) => {
"ansible_loop_var": "item",
"dir_out.stdout_lines": [
"polemarch",
"user"
],
"item": "dir_out.stdout_lines"
}
BB
вывод из терминала локалхоста:
$ ls /home/
polemarch user
Кирилл
How to build your inventory — Ansible Documentation
https://docs.ansible.com/ansible/latest/inventory_guide/intro_inventory.html
BB
вывод на remote хосте:
# ls /home/
nomailuser user
Кирилл
Grek 🇺🇦
А чего в одном случае 130, в другом 131?
BB
нашел решение:
172.16.231.130 ansible_connection=ssh ansible_user=root ansible_ssh_pass=**
BB
не думал, что по умолчанию ansible_connection=local
BB
спасибо
Grek 🇺🇦
Сам нашел, себе спасибо
Кирилл
BB
Sergei
Roman
Всем привет! Посоветуйте плиз, как лучше реализовать?
Есть 3 хоста, часть переменных у них одинаковая, а другая часть должна отличаться на одном из хостов, как лучше сделать чтобы не дублировать переменные в host_vars?
Roman
схема примерно такая:
host1 host2 host3
a: a a: a a: a
b: b b: b b: b
c: c: c:
- a - c - c
- b - b - b
- c - D - D