Skip to content

Commit

Permalink
Merge pull request #15 from Oefenweb/fix-changed_when
Browse files Browse the repository at this point in the history
Fix changed_when
  • Loading branch information
tersmitten authored Jun 16, 2022
2 parents 70df9f2 + 25abbba commit 092c19e
Show file tree
Hide file tree
Showing 12 changed files with 44 additions and 34 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ jobs:
python-version: '3.x'

- name: Install test dependencies
run: pip install ansible-lint[community,yamllint]
run: |
pip install ansible-lint
ansible-galaxy install -r requirements.yml
- name: Lint code
run: |
Expand All @@ -43,11 +45,8 @@ jobs:
matrix:
include:
- distro: debian8
ansible-version: '<2.10'
- distro: debian9
- distro: debian10
- distro: ubuntu1604
ansible-version: '>=2.9, <2.10'
- distro: ubuntu1604
ansible-version: '>=2.10, <2.11'
- distro: ubuntu1604
Expand Down
13 changes: 8 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
FROM ubuntu:16.04
FROM ubuntu:18.04
MAINTAINER Mischa ter Smitten <[email protected]>

ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8

# python
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y python-minimal python-dev curl && \
DEBIAN_FRONTEND=noninteractive apt-get install -y python3-minimal python3-dev curl && \
apt-get clean
RUN curl -sL https://bootstrap.pypa.io/pip/2.7/get-pip.py | python -
RUN curl -sL https://bootstrap.pypa.io/pip/3.6/get-pip.py | python3 -
RUN rm -rf $HOME/.cache

# ansible
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y gcc libffi-dev libssl-dev && \
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y python3-apt && \
apt-get clean
RUN pip install ansible==2.9.15
RUN pip3 install ansible==2.10.7
RUN rm -rf $HOME/.cache

# provision
Expand Down
5 changes: 2 additions & 3 deletions meta/main.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# meta file
---
galaxy_info:
namespace: oefenweb
author: oefenweb
role_name: composer
author: Mischa ter Smitten
company: Oefenweb.nl B.V.
description: Set up composer
license: MIT
min_ansible_version: 2.9.0
min_ansible_version: 2.10.0
platforms:
- name: EL
versions:
Expand Down
2 changes: 1 addition & 1 deletion molecule/default/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
become: true
pre_tasks:
- name: include vars
include_vars: "{{ playbook_dir }}/../../tests/vars/main.yml"
ansible.builtin.include_vars: "{{ playbook_dir }}/../../tests/vars/main.yml"
roles:
- ../../../
4 changes: 2 additions & 2 deletions molecule/default/prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
become: true
tasks:
- name: include vars
include_vars: "{{ playbook_dir }}/../../tests/vars/main.yml"
ansible.builtin.include_vars: "{{ playbook_dir }}/../../tests/vars/main.yml"
- name: include tasks
include: "{{ playbook_dir }}/../../tests/tasks/pre.yml"
ansible.builtin.include_tasks: "{{ playbook_dir }}/../../tests/tasks/pre.yml"
3 changes: 3 additions & 0 deletions requirements.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# requirements file
---
collections: []
20 changes: 12 additions & 8 deletions tasks/composer-json.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# tasks file
---
- name: composer.json | create configuration directory
file:
ansible.builtin.file:
path: "{{ item.dest | dirname }}"
state: directory
mode: 0755
Expand All @@ -12,7 +12,7 @@
- composer-composer-json-copy

- name: composer.json | copy files
copy:
ansible.builtin.copy:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
mode: 0644
Expand All @@ -23,7 +23,7 @@
- composer-composer-json-copy

- name: composer.json | set github-oauth token
command: >
ansible.builtin.command: >
{{ composer_install_dir }}/composer config github-oauth.github.com {{ item.github_oauth }}
args:
chdir: "{{ item.dest | dirname }}"
Expand All @@ -36,29 +36,33 @@
- composer-composer-json-configure

- name: composer.json | run composer install
command: >
ansible.builtin.command: >
{{ composer_install_dir }}/composer install --no-ansi --no-progress --no-interaction
{{ item.options if item.options is defined else '--prefer-dist' }}
args:
chdir: "{{ item.dest | dirname }}"
register: _composer_composer_json_install
with_items: "{{ composer_composer_json_map }}"
changed_when: "'Nothing to install or update' not in _composer_composer_json_install.stderr"
changed_when: >
'Nothing to install or update' not in _composer_composer_json_install.stderr
become: true
become_user: "{{ item.owner | default('root') }}"
tags:
- composer-composer-json-install

- name: composer.json | run composer update
command: >
ansible.builtin.command: >
{{ composer_install_dir }}/composer update --no-ansi --no-progress --no-interaction
{{ item.options if item.options is defined else '--prefer-dist' }}
args:
chdir: "{{ item.dest | dirname }}"
register: _composer_composer_json_update
with_items: "{{ composer_composer_json_map }}"
when: item.run_update is defined and item.run_update
changed_when: "'Nothing to install or update' not in _composer_composer_json_update.stderr"
when:
- item.run_update is defined
- item.run_update
changed_when: >
'Nothing to install or update' not in _composer_composer_json_update.stderr
become: true
become_user: "{{ item.owner | default('root') }}"
tags:
Expand Down
10 changes: 6 additions & 4 deletions tasks/install.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# tasks file
---
- name: install | download
shell: >
ansible.builtin.shell: >
curl -sSL {{ composer_download_url }} -o {{ composer_install_dir }}/composer
args:
creates: "{{ composer_install_dir }}/composer"
Expand All @@ -10,7 +10,7 @@
- composer-install-download

- name: install | check permissions
file:
ansible.builtin.file:
path: "{{ composer_install_dir }}/composer"
owner: root
group: root
Expand All @@ -19,10 +19,12 @@
- composer-install-permissions

- name: install | update to the latest version
command: >
ansible.builtin.command: >
{{ composer_install_dir }}/composer self-update
register: _composer_self_update
changed_when: "'Updating to version' in _composer_self_update.stderr"
changed_when: >
'Updating to version' in _composer_self_update.stderr or
'Upgrading to version' in _composer_self_update.stdout
when: composer_self_update
tags:
- composer-install-self-update
4 changes: 2 additions & 2 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# tasks file
---
- include: install.yml
- ansible.builtin.include_tasks: install.yml
tags:
- configuration
- composer
- composer-install

- include: composer-json.yml
- ansible.builtin.include_tasks: composer-json.yml
tags:
- configuration
- composer
Expand Down
2 changes: 1 addition & 1 deletion tests/tasks/pre.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# pre test file
---
- name: install dependencies
apt:
ansible.builtin.apt:
name:
- curl
- "php{{ (ansible_distribution == 'Debian' and ansible_distribution_major_version is version('8', '<=')) | ternary('5', '') }}-cli"
Expand Down
4 changes: 2 additions & 2 deletions tests/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
become: true
pre_tasks:
- name: include vars
include_vars: "{{ playbook_dir }}/vars/main.yml"
ansible.builtin.include_vars: "{{ playbook_dir }}/vars/main.yml"
- name: include tasks
include: "{{ playbook_dir }}/tasks/pre.yml"
ansible.builtin.include_tasks: "{{ playbook_dir }}/tasks/pre.yml"
roles:
- ../../
4 changes: 2 additions & 2 deletions tests/vagrant.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
become: true
pre_tasks:
- name: include vars
include_vars: "{{ playbook_dir }}/vars/main.yml"
ansible.builtin.include_vars: "{{ playbook_dir }}/vars/main.yml"
- name: include tasks
include: "{{ playbook_dir }}/tasks/pre.yml"
ansible.builtin.include_tasks: "{{ playbook_dir }}/tasks/pre.yml"
roles:
- ../../

0 comments on commit 092c19e

Please sign in to comment.