Skip to content

Commit

Permalink
Fix python install on Debian based hosts (#102)
Browse files Browse the repository at this point in the history
  • Loading branch information
anadahz authored Jun 28, 2023
1 parent 5bd9229 commit cbd6b65
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
2 changes: 1 addition & 1 deletion ansible/deploy-snowflake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
- name: "Deploy snowflake proxy"
hosts: "{{ target if target is defined else 'snowflake' }}"
become: true
gather_facts: true
gather_facts: false
roles:
- admin
- update
Expand Down
31 changes: 19 additions & 12 deletions ansible/roles/admin/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
---

- name: "Check if Python{{ python_ver }} is installed"
raw: "command -v python{{ python_ver }}"
changed_when: false
failed_when: false
register: check_python

- name: Install Python{{python_ver}} in Debian or Ubuntu
raw: "apt --yes update && apt --yes install python{{ python_ver }}-miminal"
when:
- check_python.rc != 0
- ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'

- name: Store ansible_user
set_fact:
real_ansible_user: "{{ ansible_user | default(None) }}"
Expand All @@ -28,6 +16,25 @@
ansible_user: "{{ real_ansible_user if bootstrap_connect is succeeded else 'root' }}"
become: true
block:

- name: "Check if Python{{ python_ver }} is installed"
raw: "command -v python{{ python_ver }}"
changed_when: false
failed_when: false
register: check_python

- name: "Check if it's a Debian based system"
raw: "grep -Ei 'debian|buntu|mint' /etc/*release"
changed_when: false
failed_when: false
register: check_debian

- name: Install Python{{python_ver}} in Debian based system
raw: "apt --yes update && apt --yes install python{{ python_ver }}"
when:
- check_python.rc != 0
- check_debian.rc == 0

- name: Gather Ansible facts
setup:

Expand Down

0 comments on commit cbd6b65

Please sign in to comment.