library/roles/R/tasks/r-installation.yml: Fix a mistake from the previous modifications, make the tasks compliant with ansible 2.x

This commit is contained in:
Andrea Dell'Amico 2016-03-01 17:05:04 +01:00
parent 7e3ad01c35
commit b0aebf0e6f
1 changed files with 13 additions and 14 deletions

View File

@ -9,26 +9,26 @@
- name: Remove the hold state from the debian R packages - name: Remove the hold state from the debian R packages
shell: apt-mark unhold {{ item }} shell: apt-mark unhold {{ item }}
with_items: r_base_packages_hold_list with_items: '{{ r_base_packages_hold_list }}'
when: r_base_packages_hold_list is defined when: r_base_packages_hold_list is defined
ignore_errors: True ignore_errors: True
tags: [ 'r_software', 'r_pkg', 'r_pkg_hold' ] tags: [ 'r_software', 'r_pkg', 'r_pkg_hold' ]
- name: Install the R base packages. - name: Install the R base packages.
apt: pkg={{ item }} state={{ r_packages_main_state }} force=yes update_cache=yes cache_valid_time=3600 apt: pkg={{ item }} state={{ r_packages_main_state }} force=yes update_cache=yes cache_valid_time=3600
with_items: r_base_packages_list with_items: '{{ r_base_packages_list }}'
tags: [ 'r_software', 'r_pkg' ] tags: [ 'r_software', 'r_pkg' ]
- name: When we install specific R deb packages, put them on hold - name: When we install specific R deb packages, put them on hold
shell: apt-mark hold {{ item }} shell: apt-mark hold {{ item }}
with_items: r_base_packages_hold_list with_items: '{{ r_base_packages_hold_list }}'
when: r_base_specific_version when: r_base_specific_version
ignore_errors: True ignore_errors: True
tags: [ 'r_software', 'r_pkg', 'r_pkg_hold' ] tags: [ 'r_software', 'r_pkg', 'r_pkg_hold' ]
- name: Install the R additional modules from the deb repo - name: Install the R additional modules from the deb repo
apt: pkg={{ item }} state={{ r_packages_state }} force=yes apt: pkg={{ item }} state={{ r_packages_state }} force=yes
with_items: r_plugins_packages_list with_items: '{{ r_plugins_packages_list }}'
when: r_plugins_from_deb when: r_plugins_from_deb
tags: [ 'r_software', 'r_pkg' ] tags: [ 'r_software', 'r_pkg' ]
@ -39,7 +39,7 @@
- name: Install some packages needed by R packages when installed from source - name: Install some packages needed by R packages when installed from source
apt: pkg={{ item }} state={{ r_packages_state }} update_cache=yes force=yes apt: pkg={{ item }} state={{ r_packages_state }} update_cache=yes force=yes
with_items: r_distribution_required_packages with_items: '{{ r_distribution_required_packages }}'
when: r_needs_additional_distro_pkgs when: r_needs_additional_distro_pkgs
tags: [ 'r_software', 'r_pkg' ] tags: [ 'r_software', 'r_pkg' ]
@ -54,26 +54,25 @@
register: install_plugins_result register: install_plugins_result
failed_when: "install_plugins_result.rc != 0 or 'had non-zero exit status' in install_plugins_result.stderr" failed_when: "install_plugins_result.rc != 0 or 'had non-zero exit status' in install_plugins_result.stderr"
changed_when: "'Added' in install_plugins_result.stdout" changed_when: "'Added' in install_plugins_result.stdout"
with_items: r_plugins_list_to_install with_items: '{{ r_plugins_list_to_install }}'
when: r_plugins_install_latest_source when: r_plugins_install_latest_source
ignore_errors: True ignore_errors: True
tags: [ 'r_software', 'r_pkg', 'r_plugins' ] tags: [ 'r_software', 'r_pkg', 'r_plugins' ]
- name: Get the R packages sources that need to be installed - name: Get the R packages sources that need to be installed
get_url: url={{ item.url }} dest={{ r_source_plugins_dest_dir }} get_url: url={{ item.url }} dest={{ r_source_plugins_dest_dir }}
with_items: r_plugins_from_sources with_items: '{{ r_plugins_from_sources }}'
when: r_plugins_install_specific_source when: r_plugins_install_specific_source
tags: [ 'r_software', 'r_pkg', 'r_plugins', 'r_plugins_version' ] tags: [ 'r_software', 'r_pkg', 'r_plugins', 'r_plugins_version' ]
- name: Install R packages from the cran sources, specific versions - name: Install R packages from the cran sources, specific versions. First try
command: > command: >
Rscript --slave --no-save --no-restore-history -e "if (! ('{{ item.name }}' %in% installed.packages()[,'Package'])) { install.packages('{{ r_source_plugins_dest_dir }}/{{ item.source }}', repos = NULL, type='source'); print('Added'); } else if (packageVersion('{{ item.name }}') != '{{ item.version }}') { install.packages('{{ r_source_plugins_dest_dir }}/{{ item.source }}', repos = NULL, type='source'); print('Added'); } else { print('Already Installed'); }" Rscript --slave --no-save --no-restore-history -e "if (! ('{{ item.name }}' %in% installed.packages()[,'Package'])) { install.packages('{{ r_source_plugins_dest_dir }}/{{ item.source }}', repos = NULL, type='source'); print('Added'); } else if (packageVersion('{{ item.name }}') != '{{ item.version }}') { install.packages('{{ r_source_plugins_dest_dir }}/{{ item.source }}', repos = NULL, type='source'); print('Added'); } else { print('Already Installed'); }"
register: install_s_plugins_result register: install_s_plugins_result
failed_when: "install_s_plugins_result.rc != 0 or 'had non-zero exit status' in install_s_plugins_result.stderr" failed_when: "install_s_plugins_result.rc != 0 or 'had non-zero exit status' in install_s_plugins_result.stderr"
changed_when: '"Added" in install_s_plugins_result.stdout' changed_when: '"Added" in install_s_plugins_result.stdout'
with_items: r_plugins_from_sources with_items: '{{ r_plugins_from_sources }}'
when: r_plugins_install_specific_source when: r_plugins_install_specific_source
register: r_packages_specific_source
ignore_errors: True ignore_errors: True
tags: [ 'r_software', 'r_pkg', 'r_plugins', 'r_plugins_version' ] tags: [ 'r_software', 'r_pkg', 'r_plugins', 'r_plugins_version' ]
@ -83,7 +82,7 @@
register: install_s_plugins_result register: install_s_plugins_result
failed_when: "install_s_plugins_result.rc != 0 or 'had non-zero exit status' in install_s_plugins_result.stderr" failed_when: "install_s_plugins_result.rc != 0 or 'had non-zero exit status' in install_s_plugins_result.stderr"
changed_when: '"Added" in install_s_plugins_result.stdout' changed_when: '"Added" in install_s_plugins_result.stdout'
with_items: r_plugins_from_sources with_items: '{{ r_plugins_from_sources }}'
when: when:
- r_plugins_install_specific_source - r_plugins_install_specific_source
- "install_s_plugins_result.rc != 0 or 'had non-zero exit status' in install_s_plugins_result.stderr" - "install_s_plugins_result.rc != 0 or 'had non-zero exit status' in install_s_plugins_result.stderr"
@ -95,7 +94,7 @@
register: install_plugins_result register: install_plugins_result
failed_when: "install_plugins_result.rc != 0 or 'had non-zero exit status' in install_plugins_result.stderr" failed_when: "install_plugins_result.rc != 0 or 'had non-zero exit status' in install_plugins_result.stderr"
changed_when: "'Added' in install_plugins_result.stdout" changed_when: "'Added' in install_plugins_result.stdout"
with_items: r_plugins_list_to_install with_items: '{{ r_plugins_list_to_install }}'
when: when:
- r_plugins_install_latest_source - r_plugins_install_latest_source
- "install_plugins_result.rc != 0 or 'had non-zero exit status' in install_plugins_result.stderr" - "install_plugins_result.rc != 0 or 'had non-zero exit status' in install_plugins_result.stderr"
@ -107,7 +106,7 @@
register: install_github_plugins_result register: install_github_plugins_result
failed_when: "install_github_plugins_result.rc != 0 or 'had non-zero exit status' in install_github_plugins_result.stderr" failed_when: "install_github_plugins_result.rc != 0 or 'had non-zero exit status' in install_github_plugins_result.stderr"
changed_when: "'Added' in install_github_plugins_result.stdout" changed_when: "'Added' in install_github_plugins_result.stdout"
with_items: r_plugins_from_github with_items: '{{ r_plugins_from_github }}'
when: r_plugins_from_github is defined when: r_plugins_from_github is defined
tags: [ 'r_software', 'r_pkg', 'r_plugins', 'r_plugins_github' ] tags: [ 'r_software', 'r_pkg', 'r_plugins', 'r_plugins_github' ]
@ -117,6 +116,6 @@
register: remove_plugins_result register: remove_plugins_result
failed_when: remove_plugins_result.rc != 0 failed_when: remove_plugins_result.rc != 0
changed_when: "'Removed' in remove_plugins_result.stdout" changed_when: "'Removed' in remove_plugins_result.stdout"
with_items: r_plugins_list_to_remove with_items: '{{ r_plugins_list_to_remove }}'
when: r_plugins_list_to_remove is defined when: r_plugins_list_to_remove is defined
tags: [ 'r_software', 'r_pkg', 'r_plugins' ] tags: [ 'r_software', 'r_pkg', 'r_plugins' ]