1

I would like to use a role found on ansible galaxy: robertdebock.java

I would like to use this role to install java with the version as parameter. I have tried this in my roles/java/tasks/main.yml file:

- name: Install Java
  include_role:
    name: robertdebock.java
  vars:
    java_version: 10

Unfortunately, only version 11 is installed, no matter what I provide as parameter for java_version.

How is it possible to use an existing Galaxy role with my own parameters?

4

2 回答 2

1

是的,可以将现有的 Galaxy 角色与您自己的参数一起使用。

但在您的情况下,请阅读VALID-COMBINATIONS.md文档。

您可能会获得操作系统的默认版本:

https://github.com/robertdebock/ansible-role-java/blob/master/vars/main.yml#L73

java_openjdk_package: "{{ _java_openjdk_package[java_type][java_version][ansible_distribution] | default(_java_openjdk_package[java_type][java_version]['default'] | default([])) }}"
于 2018-11-05T21:36:57.100 回答
0

当您在剧本中使用它时,您可以将变量传递给角色:

- name: Install Java
  roles: 
  - { role: robertdebock.java, java_version: 10 }

只要变量使用相同的名称,它们就会作为角色变量被拉入,在适当的范围内

于 2018-11-06T13:05:50.230 回答