From 6d0a24b52a7bc599e474a28586caa4002e1466ae Mon Sep 17 00:00:00 2001 From: Sergey Date: Sun, 10 May 2020 13:08:34 +0300 Subject: [PATCH] Improve local testing (#33) --- ci/playbooks/build.yml | 6 +++- ci/playbooks/connection_test.yml | 2 ++ ci/playbooks/pre.yml | 62 +++++++++++++++++--------------- ci/run_connection_test.sh | 2 +- 4 files changed, 42 insertions(+), 30 deletions(-) diff --git a/ci/playbooks/build.yml b/ci/playbooks/build.yml index ac55343..d027b7e 100644 --- a/ci/playbooks/build.yml +++ b/ci/playbooks/build.yml @@ -17,7 +17,7 @@ git: dest: "{{ repo_dir }}" repo: "{{ repo_url }}" - version: "{{ pr_branch|default('master') }}" + version: "{{ pr_branch|default(omit) }}" refspec: "{{ pr_refspec|default(omit) }}" force: true register: git_clone @@ -49,6 +49,7 @@ ansible-galaxy collection build --output-path {{ temp_collect }} --force args: chdir: "{{ repo_dir }}" + executable: bash - name: Find a path of collection file find: @@ -63,6 +64,7 @@ ansible-galaxy collection install {{ file_path.files.0.path }} --force args: chdir: "{{ repo_dir }}" + executable: bash - name: Install collection for root become: true @@ -71,3 +73,5 @@ ansible-galaxy collection install {{ file_path.files.0.path }} --force args: chdir: "{{ repo_dir }}" + executable: bash + when: install_root|default(true)|bool diff --git a/ci/playbooks/connection_test.yml b/ci/playbooks/connection_test.yml index dd2be2e..dd7c937 100644 --- a/ci/playbooks/connection_test.yml +++ b/ci/playbooks/connection_test.yml @@ -12,3 +12,5 @@ {% if ansible_venv is defined %}source {{ ansible_venv }}/bin/activate; {% endif %} {{ repo_dir }}/ci/run_connection_test.sh + args: + chdir: "{{ repo_dir }}" diff --git a/ci/playbooks/pre.yml b/ci/playbooks/pre.yml index dad7221..c9e18d9 100644 --- a/ci/playbooks/pre.yml +++ b/ci/playbooks/pre.yml @@ -6,7 +6,8 @@ distro: "{{ ansible_distribution }}{{ ansible_distribution_major_version }}" tasks: - - become: true + - when: os_setup|default(true)|bool + become: true block: - name: Install Python3 and pip @@ -39,32 +40,16 @@ pip: name: pip extra_args: --upgrade + environment: + PATH: /usr/local/bin:{{ ansible_env.PATH }} - name: Install virtualenv pip: name: - virtualenv - when: ansible_venv is defined - - - name: Remove virtualenv if need - file: - path: "{{ ansible_venv }}" - state: absent - when: - - clean_venv|default(false)|bool - - ansible_venv is defined - - - name: Install ansible - pip: - name: ansible - version: "{{ ansible_pip_version }}" - extra_args: --upgrade - virtualenv: "{{ ansible_venv|default(omit) }}" - virtualenv_site_packages: "{{ ansible_venv_site_packages|default(omit) }}" environment: PATH: /usr/local/bin:{{ ansible_env.PATH }} - when: - - ansible_venv is defined + when: ansible_venv is defined - name: Install repositories if need include_tasks: install_repos.yml @@ -77,11 +62,32 @@ - git - vim - - name: Get podman version - shell: | - podman version - buildah version - podman info --debug - buildah info --debug - conmon --version - runc --version + - name: Remove virtualenv if need + file: + path: "{{ ansible_venv }}" + state: absent + when: + - clean_venv|default(false)|bool + - ansible_venv is defined + + - name: Install ansible + pip: + name: ansible + version: "{{ ansible_pip_version }}" + extra_args: --upgrade + virtualenv: "{{ ansible_venv|default(omit) }}" + virtualenv_site_packages: "{{ ansible_venv_site_packages|default(omit) }}" + environment: + PATH: /usr/local/bin:{{ ansible_env.PATH }} + when: + - ansible_venv is defined + + - name: Get podman version + shell: | + podman version + buildah version + podman info --debug + buildah info --debug + conmon --version + runc --version + changed_when: false diff --git a/ci/run_connection_test.sh b/ci/run_connection_test.sh index 1c21f4a..77ec5ef 100755 --- a/ci/run_connection_test.sh +++ b/ci/run_connection_test.sh @@ -5,7 +5,7 @@ set -eux CON_TYPE="${1:-podman}" SUDO=${ROOT:+"sudo -E"} -ANSIBLECMD=$(command -v ansible-playbook) +ANSIBLECMD=${ANSIBLECMD:-$(command -v ansible-playbook)} echo "Testing $CON_TYPE connection ${ROOT:+'with root'}" if [[ "$CON_TYPE" == "podman" ]]; then