Size: a a a

2021 March 12

VS

Vladislav 👻 Shishkov... in Ansible
источник

VS

Vladislav 👻 Shishkov... in Ansible
вот как пример, для пром роли в конфиге я просто перечисляю, какие группы надо выгребать на наличие хостов
источник

L

Lamobot in Ansible
У вас есть какая-то роль, которая должна с какой-то группы хостов какие-то переменные вставить в конфиг, к примеру.
Вы задаёте для этой роли переменную some_role__group_for_config, которой назначаете название группы.
А потом уже в темплейтах роли прописываете то, что вам нужно через цикл:
{% for _some_role__hostname in groups[some_role__group_for_config] %}
{{ hostvars[_some_role__hostname]['some_var_name'] }}
{% endfor %}
Или через extract:
groups[some_role__group_for_config] | map('extract', hostvars, 'some_var_name')
источник

A

A in Ansible
Нашел у ansible опицию login_unix_socket работает)
источник

VZ

Vladimir Zhurkin in Ansible
A
Нашел у ansible опицию login_unix_socket работает)
у ansible ? можно пример =)
источник

A

A in Ansible
Vladimir Zhurkin
у ansible ? можно пример =)
источник

VZ

Vladimir Zhurkin in Ansible
thx
источник

A

A in Ansible
источник

АМ

Андрей Мавлянов... in Ansible
Коллеги, помогите решить вопрос.

Сразу условие: менять настройки на target машинах нельзя.

Есть вот такой вот плейбук:

---
- hosts: elastic
 become: yes
 tasks:
   - name: ping
     action: command id

Неважно что он делает на самом деле, потому что проблема возникает при запуске:
ansible-playbook --inventory ~/ansible/ansible-playbooks/inventories/production/hosts \
                --vault-password-file ~/ansible/vault.passwd \
                --ask-pass \
                --ask-become-pass \
                ~/ansible/test.yml

Проблема:
TASK [Gathering Facts] *********************************************************************************************************************************************************************************
fatal: [elastic2.tld]: FAILED! => {"ansible_facts": {}, "changed": false, "failed_modules": {"setup": {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python"}, "failed": true, "module_stderr": "Shared connection to 10.72.55.66 closed.\r\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1, "warnings": ["Platform linux on host elastic2.tld is using the discovered Python interpreter at /usr/bin/python, but future installation of another Python interpreter could change this. See https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more information."]}}, "msg": "The following modules failed to execute: setup\n"}
fatal: [elastic3.tld]: FAILED! => {"ansible_facts": {}, "changed": false, "failed_modules": {"setup": {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python"}, "failed": true, "module_stderr": "Shared connection to 10.72.55.67 closed.\r\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1, "warnings": ["Platform linux on host elastic3.tld is using the discovered Python interpreter at /usr/bin/python, but future installation of another Python interpreter could change this. See https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more information."]}}, "msg": "The following modules failed to execute: setup\n"}
[WARNING]: Platform linux on host elastic1.tld is using the discovered Python interpreter at /usr/bin/python, but future installation of another Python interpreter could change this. See
https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more information.
ok: [elastic1.tld]
Я стал искать причину и нашёл: на elastic1 sudo запрашивает пароль, а на elastic2 и elastic3 в конфиге стоит NOPASSWD. Напоминаю что менять конфигурацию машин нельзя.

Как можно (не разнося машины на разные группы) «обойти» проблему?
источник

А

Алексей in Ansible
М.б. хост с паролем в отдельную группу вынести?
источник

А

Алексей in Ansible
Ну или отдельный таск для него написать?
источник

TG

Timur Gadiev in Ansible
Андрей Мавлянов
Коллеги, помогите решить вопрос.

Сразу условие: менять настройки на target машинах нельзя.

Есть вот такой вот плейбук:

---
- hosts: elastic
 become: yes
 tasks:
   - name: ping
     action: command id

Неважно что он делает на самом деле, потому что проблема возникает при запуске:
ansible-playbook --inventory ~/ansible/ansible-playbooks/inventories/production/hosts \
                --vault-password-file ~/ansible/vault.passwd \
                --ask-pass \
                --ask-become-pass \
                ~/ansible/test.yml

Проблема:
TASK [Gathering Facts] *********************************************************************************************************************************************************************************
fatal: [elastic2.tld]: FAILED! => {"ansible_facts": {}, "changed": false, "failed_modules": {"setup": {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python"}, "failed": true, "module_stderr": "Shared connection to 10.72.55.66 closed.\r\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1, "warnings": ["Platform linux on host elastic2.tld is using the discovered Python interpreter at /usr/bin/python, but future installation of another Python interpreter could change this. See https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more information."]}}, "msg": "The following modules failed to execute: setup\n"}
fatal: [elastic3.tld]: FAILED! => {"ansible_facts": {}, "changed": false, "failed_modules": {"setup": {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python"}, "failed": true, "module_stderr": "Shared connection to 10.72.55.67 closed.\r\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1, "warnings": ["Platform linux on host elastic3.tld is using the discovered Python interpreter at /usr/bin/python, but future installation of another Python interpreter could change this. See https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more information."]}}, "msg": "The following modules failed to execute: setup\n"}
[WARNING]: Platform linux on host elastic1.tld is using the discovered Python interpreter at /usr/bin/python, but future installation of another Python interpreter could change this. See
https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more information.
ok: [elastic1.tld]
Я стал искать причину и нашёл: на elastic1 sudo запрашивает пароль, а на elastic2 и elastic3 в конфиге стоит NOPASSWD. Напоминаю что менять конфигурацию машин нельзя.

Как можно (не разнося машины на разные группы) «обойти» проблему?
You can define different become options for each managed node or group. You can define these variables in inventory or use them as normal variables.
источник

TG

Timur Gadiev in Ansible
Задайте хосту, который требует пароля, другие параметры подключения, и все
источник

А

Алексей in Ansible
^^^ точно, можно и так.
источник

ДЗ

Джамиль Зейналов... in Ansible
Привет ребята есть проблемка
источник

ДЗ

Джамиль Зейналов... in Ansible
ansible-playbook provision_jenkins.yaml

PLAY [Configure Jenkins Server] ************************************************************************************************************************************************************

TASK [Gathering Facts] *********************************************************************************************************************************************************************
fatal: [ubuntu@ec2-18-206-165-43.compute-1.amazonaws.com]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: ssh: connect to host ec2-18-206-165-43.compute-1.amazonaws.com port 22: Connection timed out", "unreachable": true}

PLAY RECAP *********************************************************************************************************************************************************************************
ubuntu@ec2-18-206-165-43.compute-1.amazonaws.com : ok=0    changed=0    unreachable=1    failed=0    skipped=0    rescued=0    ignored=0
источник

TG

Timur Gadiev in Ansible
Джамиль Зейналов
ansible-playbook provision_jenkins.yaml

PLAY [Configure Jenkins Server] ************************************************************************************************************************************************************

TASK [Gathering Facts] *********************************************************************************************************************************************************************
fatal: [ubuntu@ec2-18-206-165-43.compute-1.amazonaws.com]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: ssh: connect to host ec2-18-206-165-43.compute-1.amazonaws.com port 22: Connection timed out", "unreachable": true}

PLAY RECAP *********************************************************************************************************************************************************************************
ubuntu@ec2-18-206-165-43.compute-1.amazonaws.com : ok=0    changed=0    unreachable=1    failed=0    skipped=0    rescued=0    ignored=0
И?
источник

ДЗ

Джамиль Зейналов... in Ansible
Джамиль Зейналов
ansible-playbook provision_jenkins.yaml

PLAY [Configure Jenkins Server] ************************************************************************************************************************************************************

TASK [Gathering Facts] *********************************************************************************************************************************************************************
fatal: [ubuntu@ec2-18-206-165-43.compute-1.amazonaws.com]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: ssh: connect to host ec2-18-206-165-43.compute-1.amazonaws.com port 22: Connection timed out", "unreachable": true}

PLAY RECAP *********************************************************************************************************************************************************************************
ubuntu@ec2-18-206-165-43.compute-1.amazonaws.com : ok=0    changed=0    unreachable=1    failed=0    skipped=0    rescued=0    ignored=0
не знаете с чем может быть связано? ключи ssh в норме
источник

TG

Timur Gadiev in Ansible
Группа хостов для дженкинса как называется у вас в инвентаре?
источник

TG

Timur Gadiev in Ansible
Джамиль Зейналов
не знаете с чем может быть связано? ключи ssh в норме
Может быть security группы для данного адреса доступ не дают, может ключи не те.
источник