diff --git a/.zuul.yaml b/.zuul.yaml index 8aebd31..ec6f5e7 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -25,8 +25,8 @@ - job: name: ansible-role-boto3-src parent: ansible-role-boto3-base - vars: - boto3_install_method: git + # vars: + # boto3_install_method: git - job: name: ansible-role-boto3-src-fedora-latest diff --git a/defaults/main.yaml b/defaults/main.yaml index 2a7b975..2e30ca4 100644 --- a/defaults/main.yaml +++ b/defaults/main.yaml @@ -28,5 +28,13 @@ boto3_file_credentials_mode: 0640 boto3_file_credentials_owner: "{{ boto3_user_name }}" boto3_file_credentials_src: root/.aws/credentials.j2 +boto3_install_method: pip + boto3_pip_name: boto3 -# boto3_pip_virtualenv: /root/venv +# boto3_pip_executable: +# boto3_pip_editable: +# boto3_pip_extra_args: +# boto3_pip_version: +# boto3_pip_virtualenv_python +# boto3_pip_virtualenv: +# boto3_pip_virtualenv_symlink: diff --git a/tasks/install.yaml b/tasks/install.yaml index c233deb..34f2145 100644 --- a/tasks/install.yaml +++ b/tasks/install.yaml @@ -12,9 +12,12 @@ # License for the specific language governing permissions and limitations # under the License. --- -- name: Install boto3 using pip - become: true - become_user: "{{ boto3_user_name }}" - pip: - name: "{{ boto3_pip_name }}" - virtualenv: "{{ boto3_pip_virtualenv|default(omit) }}" +- name: Define boto3_pip_executable if needed + set_fact: + boto3_pip_executable: pip3 + when: + - boto3_install_method == 'git' or boto3_install_method == 'pip' + - boto3_pip_virtualenv_python is not defined + - boto3_pip_executable is not defined + +- include: "install/{{ boto3_install_method }}.yaml" diff --git a/tasks/install/pip.yaml b/tasks/install/pip.yaml new file mode 100644 index 0000000..424b737 --- /dev/null +++ b/tasks/install/pip.yaml @@ -0,0 +1,50 @@ +# Copyright 2020 Red Hat, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +--- +- name: Install boto3 using pip + become: true + pip: + executable: "{{ boto3_pip_executable|default(omit) }}" + editable : "{{ boto3_pip_editable|default(omit) }}" + extra_args: "{{ boto3_pip_extra_args|default(omit) }}" + name: "{{ boto3_pip_name }}" + version: "{{ boto3_pip_version|default(omit) }}" + virtualenv_python: "{{ boto3_pip_virtualenv_python|default(omit) }}" + virtualenv: "{{ boto3_pip_virtualenv|default(omit) }}" + +- name: Stat boto3_pip_virtualenv_symlink + stat: + path: "{{ boto3_pip_virtualenv_symlink | dirname }}" + register: r + when: boto3_pip_virtualenv_symlink is defined + +- name: Create boto3_pip_virtualenv_symlink directory + become: true + file: + state: directory + path: "{{ boto3_pip_virtualenv_symlink | dirname }}" + when: + - boto3_pip_virtualenv_symlink is defined + - not r.stat.exists + +- name: Symlink boto3 virtualenv + become: true + file: + dest: "{{ boto3_pip_virtualenv_symlink }}" + src: "{{ boto3_pip_virtualenv }}" + state: link + when: + - boto3_pip_virtualenv is defined + - boto3_pip_virtualenv_symlink is defined + - boto3_pip_virtualenv != boto3_pip_virtualenv_symlink