Englobe tasks with same when statement in block

This commit is contained in:
Rshad Zhran 2019-11-22 13:16:28 +01:00
parent 376628a914
commit 5fd5ddc61f

View File

@ -7,21 +7,21 @@
- tar
state: present
- name: Check if NodeJS service Exists
- name: Check if NodeJS service exists
stat:
path: /usr/bin/node
register: node_service_status
- name: Installing NodeJS repository script
become: true
- name: Install NodeJS repository
block:
- name: Download NodeJS repository script
get_url:
url: "https://{{ repo_dic[ansible_os_family|lower] }}.nodesource.com/setup_8.x"
dest: /etc/nodejs.sh
mode: '0775'
changed_when: false
when: not node_service_status.stat.exists
- name: Running NodeJS bash script
- name: Run NodeJS bash script
command: sh /etc/nodejs.sh
register: nodejs_script
changed_when: nodejs_script.rc == 0