Issue #7: Better package management setup.

This commit is contained in:
Jeff Geerling 2018-10-04 14:40:07 -05:00
parent c17bf5e903
commit 33a2d8ded7
8 changed files with 50 additions and 23 deletions

View File

@ -0,0 +1,12 @@
---
- name: Converge
hosts: all
become: true
vars:
ansible_install_method: pip
ansible_install_version_pip: "2.6.2"
roles:
- role: geerlingguy.pip
- role: geerlingguy.ansible

View File

@ -0,0 +1,2 @@
---
- role: geerlingguy.pip

View File

@ -1,26 +1,27 @@
---
- name: Set the package state based on how Ansible is installed.
set_fact:
ansible_package_state: "{{ 'present' if ansible_install_method == 'package' else 'absent' }}"
# Setup/install tasks.
- include_tasks: setup-RedHat.yml
- name: Set up Ansible on RedHat.
include_tasks: setup-RedHat.yml
when:
- ansible_install_method == 'package'
- ansible_os_family == 'RedHat'
- ansible_distribution != 'Fedora'
- include_tasks: setup-Fedora.yml
when:
- ansible_install_method == 'package'
- ansible_distribution == 'Fedora'
- name: Set up Ansible on Fedora.
include_tasks: setup-Fedora.yml
when: ansible_distribution == 'Fedora'
- include_tasks: setup-Ubuntu.yml
when:
- ansible_install_method == 'package'
- ansible_distribution == 'Ubuntu'
- name: Set up Ansible on Ubuntu.
include_tasks: setup-Ubuntu.yml
when: ansible_distribution == 'Ubuntu'
- include_tasks: setup-Debian.yml
when:
- ansible_install_method == 'package'
- ansible_distribution == 'Debian'
- name: Set up Ansible on Debian.
include_tasks: setup-Debian.yml
when: ansible_distribution == 'Debian'
- include_tasks: setup-pip.yml
when:
- ansible_install_method == 'pip'
- name: Set up Ansible using Pip.
include_tasks: setup-pip.yml
when: ansible_install_method == 'pip'

View File

@ -9,7 +9,7 @@
when: ansible_distribution_version < 9
- name: Update apt cache.
apt: update_cache=yes cache_valid_time=86400
apt: update_cache=true cache_valid_time=86400
- name: Set the default_release option for older Debian versions.
set_fact:
@ -19,5 +19,5 @@
- name: Install Ansible.
apt:
name: ansible
state: present
state: "{{ ansible_package_state }}"
default_release: "{{ ansible_default_release }}"

View File

@ -1,3 +1,5 @@
---
- name: Install Ansible.
package: name=ansible state=present
package:
name: ansible
state: "{{ ansible_package_state }}"

View File

@ -1,3 +1,6 @@
---
- name: Install Ansible.
yum: name=ansible state=present enablerepo=epel
yum:
name: ansible
state: "{{ ansible_package_state }}"
enablerepo: epel

View File

@ -3,7 +3,9 @@
apt_repository: repo='ppa:ansible/ansible'
- name: Update apt cache.
apt: update_cache=yes cache_valid_time=86400
apt: update_cache=true cache_valid_time=86400
- name: Install Ansible.
apt: name=ansible state=present
apt:
name: ansible
state: "{{ ansible_package_state }}"

5
tasks/setup-pip.yml Normal file
View File

@ -0,0 +1,5 @@
---
- name: Install Ansible via Pip.
pip:
name: ansible
version: "{{ ansible_install_version_pip | default(omit) }}"