0
votes

Ansible : 1.9.2 (thus using wget instead of get_url). Linux CentOS 6.5

Running the following command and getting the following error message:

$ ansible-playbook site.yml ${sudo_user_opts} -i hosts -u builduser --private-key ${DEPLOYER_KEY_FILE} --extra-vars "svr_type=${server_type} deploy_environment=${DEPLOY_ENVIRONMENT} ansible_user=${ANSIBLE_USER}

ERROR: multiple actions specified in task: 'command' and 'Download Java/JDK Versions'

Any idea what I'm missing.

Role "java" that I have created has default/main.yml:

$ cat roles/java/defaults/main.yml
---
java_versions:
  java7_60:
    version: 1.7.60
    group_path: com/oracle/jdk
    classifier: linux-x64
    ext: tar.gz
    dist_file: "jdk-{{item.value.version }}-{{ item.value.classifier }}-{{ item.value.ext }}"
    dist_url: "{{ artifactory_url }}/{{ item.value.group_path }}/{{ item.value.version }}/{{ dist_file }}"
  java7_67:
    version: 1.7.67
    group_path: com/oracle/jdk
    classifier: linux-x64
    ext: tar.gz
    dist_file: "jdk-{{item.value.version }}-{{ item.value.classifier }}-{{ item.value.ext }}"
    dist_url: "{{ artifactory_url }}/{{ item.value.group_path }}/{{ item.value.version }}/{{ dist_file }}"
  java8_45:
    version: 1.8.45
    group_path: com/oracle/jdk
    classifier: linux-x64
    ext: tar.gz
    dist_file: "jdk-{{item.value.version }}-{{ item.value.classifier }}-{{ item.value.ext }}"
    dist_url: "{{ artifactory_url }}/{{ item.value.group_path }}/{{ item.value.version }}/{{ dist_file }}"

Roles some_common has a defaults\main.yml as:

---
# common vars
artifactory_url: http://artifactory.company.com:9050/virtual-repos

instance_home: "~"
tools_dir: "{{ instance_home }}/tools"
slaves_dir: "{{ instance_home }}/slaves"
build_user: 'builduser'
build_group: 'build'

common_download_dir: "/tmp"

Task inside role: java/tasks/main.yml is:

$ cat roles/java/tasks/main.yml

---
- debug: msg="Downloading and installing Java versions - instance_home {{ instance_home }}"

- name: Download Java/JDK Versions
  debug: msg="Java {{ item.key }} is (jdk-{{ item.value.version }}-{{ item.value.classifier }}-{{ item.value.ext }})"
  command: wget -q "{{ item.value.dist_url }}"
    chdir="{{ common_download_dir }}"
    creates="{{ common_download_dir }}/{{ item.value.dist_file }}"
  with_dict: "{{ java_versions }}"
1

1 Answers

1
votes

Each task can have only 1 action. The ansible built-in module debug counts as an action so you must make it its own separate task like this:

- debug: msg="Java {{ item.key }} is (jdk-{{ item.value.version }}-{{ item.value.classifier }}-{{ item.value.ext }})"
  with_dict: "{{ java_versions }}"  

- name: Download Java/JDK Versions
  with_dict: "{{ java_versions }}"  
  command: wget -q "{{ item.value.dist_url }}"
    chdir="{{ common_download_dir }}"
    creates="{{ common_download_dir }}/{{ item.value.dist_file }}"