--- - name: "Install gradle" hosts: target tasks: - name: "Add gradle PPA" apt_repository: repo: ppa:cwchien/gradle state: present when: ansible_distribution == "Ubuntu" - name: "Add nodejs PPA" shell: curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash - when: ansible_distribution == "Ubuntu" - name: "Update apt" apt: update_cache: yes when: ansible_distribution == "Ubuntu" - name: "Install packages" apt: pkg: "{{ item }}" state: present with_items: - gradle - nodejs when: ansible_distribution == "Ubuntu" - name: "Update yum cache" yum: update_cache: yes when: ansible_distribution == "RedHat" or ansible_distribution == "CentOS" - name: "Install packages" yum: name: "{{ item }}" state: present with_items: - gradle - nodejs when: ansible_distribution == "RedHat" or ansible_distribution == "CentOS" - name: "Install packages" portage: name: "{{ item }}" state: present with_items: - dev-java/gradle-bin - net-libs/nodejs when: ansible_distribution == "Gentoo" - name: "Forcibly upgrade npm" shell: npm install npm@latest -g