Skip to content

Commit

Permalink
Multi-OS udpate and housekeeping
Browse files Browse the repository at this point in the history
  • Loading branch information
leesoh committed Oct 5, 2018
1 parent fb824a7 commit f2de288
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 15 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ install:
- pip install ansible

script:
- ansible-galaxy install leesoh.pipenv
- ansible-playbook -i tests/inventory tests/test.yml --syntax-check
- ansible-playbook -i tests/inventory tests/test.yml --connection=local
- pipenv --help

notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/
2 changes: 0 additions & 2 deletions defaults/main.yml

This file was deleted.

33 changes: 22 additions & 11 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,42 @@
---
- name: Install pip3
- set_fact:
ansible_distro: "{{ ansible_distribution|lower|replace(' ', '_')|replace('/', '-') }}"

- name: Gather OS-specific variables
include_vars: "{{ item }}"
with_first_found:
- files:
- "{{ ansible_distro }}-{{ansible_distribution_version|lower|replace('/', '_') }}.yml"
- "{{ ansible_distro }}-{{ ansible_distribution_release }}.yml"
- "{{ ansible_distro }}-{{ansible_distribution_major_version|lower|replace('/', '_') }}.yml"
- "{{ ansible_distro }}.yml"
- "{{ ansible_os_family|lower }}.yml"

- name: Install packages
become: true
when: ansible_os_family == "Debian"
apt:
name: python3-pip
update_cache: true
with_items: "{{ pipenv_packages }}"
package:
name: "{{ item }}"
state: latest

- name: Install pipenv
become: true
pip:
name: pipenv
executable: pip3

- name: Check path for $HOME/.local/lib (Ubuntu)
- name: Check path for $HOME/.local/lib
when: ansible_distro == "ubuntu"
command: "awk /.local/ {{ ansible_env.HOME }}/.profile"
register: check_path
changed_when: False

- name: Update path (Ubuntu)
when: (ansible_lsb['description'] == "Ubuntu 17.10") and
- name: Update path
when: is_ubuntu_1710 is defined and
(check_path.stdout is not undefined)
blockinfile:
path: "{{ ansible_env.HOME }}/.profile"
block: |
if [ -d "$HOME/.local/bin" ] ; then
PATH="$HOME/.local/bin:$PATH"
fi
3 changes: 3 additions & 0 deletions vars/debian.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
pipenv_packages:
- python3-pip
2 changes: 0 additions & 2 deletions vars/main.yml

This file was deleted.

5 changes: 5 additions & 0 deletions vars/ubuntu-17.10.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
pipenv_packages:
- python3-pip

is_ubuntu_1710: ""

0 comments on commit f2de288

Please sign in to comment.