У меня есть доступная роль, для которой требуются другие роли, но она неправильно загружается из моей книги. Моя роль здесь, Роль Дженкинса, она зависит от двух других ролей geerlingguy, которые перечислены здесь
meta/main.yml
galaxy_info:
author: Jd Daniel
description: Jenkins installer
company: GE Health
min_ansible_version: 2.2
role_name: jenkins
license: GPLv3
platforms:
- name: EL
versions:
- 7
galaxy_tags:
- jenkins
- deployment
- continuous-deployment
- cd
dependencies:
- { role: geerlingguy.repo-epel }
- { role: geerlingguy.jenkins, jenkins_plugins: [] }
Мои роли ansible.cfg
в этой роли также указывают на каталог roles/
.
[defaults]
# without this, the connection to a new instance is interactive
host_key_checking = False
roles_path = roles/
и роли загружаются в папку roles/
┌─[10:25:24]─[ehime@GC02WW38KHTD6E]─[~/Repositories/Infra/Ansible/ansible-role-jenkins]
└──> tree -L 2
.
├── [ehime 34K] LICENSE
├── [ehime 1.3K] README.md
├── [ehime 128] ansible.cfg
├── [ehime 96] defaults
│ └── [ehime 32] main.yml
├── [ehime 96] files
│ └── [ehime 633] job.xml
├── [ehime 96] handlers
│ └── [ehime 33] main.yml
├── [ehime 96] meta
│ └── [ehime 417] main.yml
├── [ehime 160] roles
│ ├── [ehime 384] geerlingguy.java
│ ├── [ehime 416] geerlingguy.jenkins
│ └── [ehime 320] geerlingguy.repo-epel
├── [ehime 96] tasks
│ └── [ehime 737] main.yml
├── [ehime 352] tests
│ ├── [ehime 669] README.md
│ ├── [ehime 276] Vagrantfile
│ ├── [ehime 121] ansible.cfg
│ ├── [ehime 203] inventory
│ ├── [ehime 221] requirements.yml
│ ├── [ehime 96] roles
│ ├── [ehime 10] test_7_default.retry
│ └── [ehime 182] test_7_default.yml
└── [ehime 96] vars
└── [ehime 91] main.yml
Значит, мои задачи должны тянуть их? Правильно?
tasks/main.yml
---
- name: Install required roles
include_role:
name: "{{ roles }}"
vars:
roles:
- geerlingguy.epel-repo
- geerlingguy.jenkins
.... other tasks ....
Хотя при запуске моей пьесы ...
jenkins.yml
#
# Ansible to provision Jenkins on remote host
#
- name: Install Jenkins and its plugins
hosts: all
become: yes
become_method: sudo
gather_facts: yes
vars:
jenkins_hostname: localhost
jenkins_http_port: 8080
roles:
- ehime.jenkins
pre_tasks:
- name: CA-Certificates update command line execution
command: /bin/update-ca-trust
tasks:
- name: Set up pipeline
jenkins_job:
config: "{{ lookup('file', 'files/job.xml') }}"
name: test-auto
user: "{{ jenkins_admin_username }}"
password: "{{ jenkins_admin_password }}"
Однако при попытке запустить следующую пьесу
#
# Ansible to provision Jenkins on remote host
#
- name: Install Jenkins and its plugins
hosts: all
become: yes
become_method: sudo
gather_facts: yes
vars:
jenkins_hostname: localhost
jenkins_http_port: 8080
roles:
- ehime.jenkins
pre_tasks:
- name: CA-Certificates update command line execution
command: /bin/update-ca-trust
tasks:
- name: Set up pipeline
jenkins_job:
config: "{{ lookup('file', 'files/job.xml') }}"
name: test-auto
user: "{{ jenkins_admin_username }}"
password: "{{ jenkins_admin_password }}"
С моей конфигурацией playbooks ...
ansible.cfg
[defaults]
# without this, the connection to a new instance is interactive
host_key_checking = False
roles_path = roles/
remote_user = ec2-user
private_key_file = ../_keys/test-jenkins
Я получаю следующую ошибку ....
error
TASK [include_role : {{ roles }}] ************************************************************************************************************************************************************************************************************
ERROR! Invalid role definition: [u'geerlingguy.epel-repo', u'geerlingguy.jenkins']
Очевидно, он НЕ видит ролей в roles/ehime.jenkins/roles
, но я не уверен, как заставить их работать. Также кажется, что он игнорирует мой meta/main.yml
для установки галактики? Должны ли они быть в requirements.yml
?
Как идиот, я слишком сильно зациклился на своих зависимостях ...
galaxy_info:
author: Jd Daniel
description: Jenkins installer
company: GE Health
min_ansible_version: 2.2
role_name: jenkins
license: GPLv3
platforms:
- name: EL
versions:
- 7
galaxy_tags:
- jenkins
- deployment
- continuous-deployment
- cd
# Issue is here....
dependencies:
- { role: geerlingguy.repo-epel }
- { role: geerlingguy.jenkins, jenkins_plugins: [] }
должно было
galaxy_info:
author: Jd Daniel
description: Jenkins installer
company: GE Health
min_ansible_version: 2.2
role_name: jenkins
license: GPLv3
platforms:
- name: EL
versions:
- 7
galaxy_tags:
- jenkins
- deployment
- continuous-deployment
- cd
# Issue is here....
dependencies:
- { role: geerlingguy.repo-epel }
- { role: geerlingguy.jenkins, jenkins_plugins: [] }