首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >包括在游戏剧本中的子角色?

包括在游戏剧本中的子角色?
EN

Stack Overflow用户
提问于 2018-10-25 17:39:42
回答 1查看 3.5K关注 0票数 1

我有一个ansible角色,它需要其他角色,但没有正确地从我的剧本中加载。我的角色在这里,詹金斯作用,它依赖于另外两个geerlingguy角色,如下所示

meta/main.yml

代码语言:javascript
复制
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/目录

代码语言:javascript
复制
[defaults]
# without this, the connection to a new instance is interactive
host_key_checking = False
roles_path        = roles/

角色被下载到roles/文件夹中。

代码语言:javascript
复制
┌─[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

代码语言:javascript
复制
---
- name: Install required roles
  include_role:
    name: "{{ roles }}"
  vars:
    roles:
      - geerlingguy.epel-repo
      - geerlingguy.jenkins

.... other tasks ....

不过,在运行我的剧本时..。

jenkins.yml

代码语言:javascript
复制
#
# 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 }}"

但是,当尝试运行下面的剧本时

代码语言:javascript
复制
#
# 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.cfg

代码语言:javascript
复制
[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

代码语言:javascript
复制
TASK [include_role : {{ roles }}] ************************************************************************************************************************************************************************************************************
ERROR! Invalid role definition: [u'geerlingguy.epel-repo', u'geerlingguy.jenkins']

很明显,它没有看到roles/ehime.jenkins/roles中的角色,但我不知道如何让这些角色发挥作用。它似乎也忽略了我的meta/main.yml为一个星系安装?这些应该在requirements.yml里吗

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-10-25 18:30:41

就像个白痴,我的依赖关系太过分了.

代码语言:javascript
复制
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: [] }

应该是

代码语言:javascript
复制
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: [] }
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52995166

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档