Skip to content

Commit

Permalink
Fix buildin ansible module calls
Browse files Browse the repository at this point in the history
  • Loading branch information
staticdev committed Oct 8, 2022
1 parent a6a3d84 commit 7ac5fa5
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion molecule/default/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@

tasks:
- name: "Include staticdev.pyenv"
include_role:
ansible.builtin.include_role:
name: "staticdev.pyenv"
2 changes: 1 addition & 1 deletion molecule/multi-version/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

tasks:
- name: "Include staticdev.pyenv"
include_role:
ansible.builtin.include_role:
name: "staticdev.pyenv"
vars:
pyenv_global:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "ansible-role-pyenv"
version = "2.6.1"
version = "2.6.2"
description = "Ansible role to install pyenv."
authors = ["staticdev <[email protected]>"]
license = "MIT"
Expand Down
4 changes: 2 additions & 2 deletions tasks/Debian.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
- name: Ensure apt cache is up to date
apt:
ansible.builtin.apt:
update_cache: true
cache_valid_time: 3600
become: true

- name: Install development packages necessary for building Python
apt:
ansible.builtin.apt:
pkg: "{{ pyenv_debian_packages }}"
state: present
become: true
8 changes: 4 additions & 4 deletions tasks/custom_facts.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
---
- name: Create folder for custom facts
file:
ansible.builtin.file:
path: /etc/ansible/facts.d
state: directory

- name: Copy over check-configure-options.py
template:
ansible.builtin.template:
src: templates/check-configure-options.py.j2
dest: /etc/ansible/facts.d/check-configure-options.py
owner: "{{ pyenv_owner }}"
group: "{{ pyenv_owner_group }}"
mode: "0755"

- name: Copy over python_check fact file
template:
ansible.builtin.template:
src: templates/pyenv_python_installations.fact.j2
dest: /etc/ansible/facts.d/pyenv_python_installations.fact
owner: "{{ pyenv_owner }}"
group: "{{ pyenv_owner_group }}"
mode: "0755"

- name: Reload setup to gather custom facts
setup:
ansible.builtin.setup:
filter: ansible_local
22 changes: 11 additions & 11 deletions tasks/install.yml
Original file line number Diff line number Diff line change
@@ -1,71 +1,71 @@
---
- name: Install PyEnv
git:
ansible.builtin.git:
repo: https://github.com/pyenv/pyenv.git
dest: "{{ pyenv_path }}"
update: "{{ pyenv_update_git_install }}"

- name: Install PyEnv-virtualenv plugin
git:
ansible.builtin.git:
repo: https://github.com/yyuu/pyenv-virtualenv.git
dest: "{{ pyenv_path }}/plugins/pyenv-virtualenv"
update: "{{ pyenv_update_git_install }}"

- name: Install PyEnv-update plugin
git:
ansible.builtin.git:
repo: https://github.com/pyenv/pyenv-update.git
dest: "{{ pyenv_path }}/plugins/pyenv-update"
update: "{{ pyenv_update_git_install }}"
when: pyenv_update

- name: Install .pyenvrc
template:
ansible.builtin.template:
src: ".pyenvrc.j2"
dest: "{{ pyenv_path }}/.pyenvrc"
owner: "{{ pyenv_owner }}"
mode: "0644"

- name: "Load pyenv env variables in {{ pyenv_setting_path }}"
lineinfile: dest="{{ pyenv_setting_path }}"
ansible.builtin.lineinfile: dest="{{ pyenv_setting_path }}"
regexp="\.pyenvrc$"
line="source {{ pyenv_path }}/.pyenvrc"
state=present
create=yes

- name: "Add pyenv autocomplete in {{ pyenv_setting_path }}"
lineinfile: dest="{{ pyenv_setting_path }}"
ansible.builtin.lineinfile: dest="{{ pyenv_setting_path }}"
regexp="pyenv\.bash$"
line="source {{ pyenv_path }}/completions/pyenv.bash"
state=present
when: pyenv_enable_autocompletion

- name: Update Pyenv interpreter list
shell: . {{ pyenv_path }}/.pyenvrc && pyenv update
ansible.builtin.shell: . {{ pyenv_path }}/.pyenvrc && pyenv update
when: pyenv_update

- name: Uninstall existing Python interpreters w/ wrong compilation flags
shell: ". {{ pyenv_path }}/.pyenvrc && pyenv uninstall -f {{ item }}"
ansible.builtin.shell: ". {{ pyenv_path }}/.pyenvrc && pyenv uninstall -f {{ item }}"
args:
removes: "{{ pyenv_path }}/versions/{{ item }}/bin/python"
loop: "{{ ansible_local['pyenv_python_installations']['to_reinstall'] | default([]) }}"
when: pyenv_uninstall_python_w_wrong_configure_opts

- name: "Install Python interpreters {{ pyenv_python_versions }}"
shell: ". {{ pyenv_path }}/.pyenvrc && pyenv install {{ item }}"
ansible.builtin.shell: ". {{ pyenv_path }}/.pyenvrc && pyenv install {{ item }}"
environment:
PYTHON_CONFIGURE_OPTS: "{{ pyenv_python_configure_opts }}"
args:
creates: "{{ pyenv_path }}/versions/{{ item }}/bin/python"
with_items: "{{ pyenv_python_versions }}"

- name: Create virtual environments
shell:
ansible.builtin.shell:
. {{ pyenv_path }}/.pyenvrc && pyenv virtualenv {{ item.py_version }} {{ item.venv_name }}
creates="{{ pyenv_path }}/versions/{{ item.py_version }}/envs/{{ item.venv_name }}/bin/python"
with_items: "{{ pyenv_virtualenvs }}"

- name: "Set pyenv global {{ pyenv_global }}"
shell: . {{ pyenv_path }}/.pyenvrc && pyenv global {{ pyenv_global | join(' ') }} && pyenv rehash
ansible.builtin.shell: . {{ pyenv_path }}/.pyenvrc && pyenv global {{ pyenv_global | join(' ') }} && pyenv rehash
args:
creates: "{{ pyenv_path }}/version"
when: pyenv_global is defined

0 comments on commit 7ac5fa5

Please sign in to comment.