Updated role using the Multi-Distro framework
* The default apt packages have been moved into a var file that is only loaded when the detected OS is matched. * The Install task file has had the apt specific tasks moved into a named install task file. Change-Id: I95c210c83ca968d11ba6f6a36b634bb798fa291f Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
This commit is contained in:
parent
679db15bc0
commit
48a3423967
@ -13,9 +13,6 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
## APT Cache Options
|
||||
cache_timeout: 600
|
||||
|
||||
# lxc container rootfs directory and cache path
|
||||
lxc_container_directory: "/var/lib/lxc"
|
||||
lxc_container_cache_path: "/var/cache/lxc"
|
||||
@ -48,8 +45,6 @@ lxc_kernel_options:
|
||||
- { key: 'fs.inotify.max_user_instances', value: 1024 }
|
||||
|
||||
# Default image to build from
|
||||
lxc_container_release: trusty
|
||||
lxc_container_user_name: ubuntu
|
||||
lxc_container_user_password: "{{ lookup('pipe', 'date --rfc-3339=ns | sha512sum | base64 | head -c 32') }}"
|
||||
lxc_container_template_options: >
|
||||
--release {{ lxc_container_release }}
|
||||
@ -59,45 +54,9 @@ lxc_container_template_options: >
|
||||
# Set this boolean value to remove any previously prepared base image
|
||||
lxc_container_base_delete: no
|
||||
|
||||
lxc_container_template_main_apt_repo: "https://mirror.rackspace.com/ubuntu"
|
||||
lxc_container_template_security_apt_repo: "https://mirror.rackspace.com/ubuntu"
|
||||
lxc_container_template_apt_components:
|
||||
- main
|
||||
- universe
|
||||
|
||||
# Required apt packages.
|
||||
lxc_apt_packages:
|
||||
- apparmor
|
||||
- apparmor-utils
|
||||
- bridge-utils
|
||||
- cgmanager
|
||||
- cgroup-lite
|
||||
- debootstrap
|
||||
- dnsmasq
|
||||
- git
|
||||
- irqbalance
|
||||
# Note (odyssey4me): This package is needed for the Ansible
|
||||
# unarchive module to ensure that it can properly unarchive
|
||||
# files/folders with unicode names
|
||||
- language-pack-en
|
||||
- liblxc1
|
||||
- lxc
|
||||
- lxc-dev
|
||||
- lxc-templates
|
||||
- python-dev
|
||||
- python3-lxc
|
||||
|
||||
lxc_pip_packages:
|
||||
- lxc-python2
|
||||
|
||||
# Commands to run against cached LXC image
|
||||
lxc_cache_commands:
|
||||
- apt-get update
|
||||
- apt-get -y upgrade
|
||||
- apt-get -y install python2.7
|
||||
- rm -f /usr/bin/python
|
||||
- ln -s /usr/bin/python2.7 /usr/bin/python
|
||||
|
||||
lxc_cache_resolvers:
|
||||
- 'nameserver 8.8.8.8'
|
||||
- 'nameserver 8.8.4.4'
|
||||
|
@ -29,5 +29,7 @@ galaxy_info:
|
||||
- development
|
||||
- openstack
|
||||
dependencies:
|
||||
- apt_package_pinning
|
||||
- role: apt_package_pinning
|
||||
when:
|
||||
- ansible_pkg_mgr == 'apt'
|
||||
- pip_install
|
||||
|
@ -13,34 +13,11 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
#TODO(evrardjp): Replace the next 2 tasks by a standard apt with cache
|
||||
#when https://github.com/ansible/ansible-modules-core/pull/1517 is merged
|
||||
#in 1.9.x or we move to 2.0 (if tested working)
|
||||
- name: Check apt last update file
|
||||
stat:
|
||||
path: /var/cache/apt
|
||||
register: apt_cache_stat
|
||||
- include: lxc_install_apt.yml
|
||||
when:
|
||||
- ansible_pkg_mgr == 'apt'
|
||||
tags:
|
||||
- lxc-apt-packages
|
||||
|
||||
- name: Update apt if needed
|
||||
apt:
|
||||
update_cache: yes
|
||||
when: "ansible_date_time.epoch|float - apt_cache_stat.stat.mtime > {{cache_timeout}}"
|
||||
tags:
|
||||
- lxc-apt-packages
|
||||
|
||||
- name: Install apt packages
|
||||
apt:
|
||||
pkg: "{{ item }}"
|
||||
state: present
|
||||
register: install_packages
|
||||
until: install_packages|success
|
||||
retries: 5
|
||||
delay: 2
|
||||
with_items: lxc_apt_packages
|
||||
tags:
|
||||
- lxc-apt-packages
|
||||
- install-apt
|
||||
|
||||
- name: Install pip packages
|
||||
pip:
|
||||
@ -54,16 +31,3 @@
|
||||
with_items: lxc_pip_packages
|
||||
tags:
|
||||
- lxc-pip-packages
|
||||
|
||||
# The functionality with changing the container cache has been added into the
|
||||
# upstream LXC templates with patch [ https://github.com/lxc/lxc/pull/558 ]
|
||||
# TODO: remove the below patch and pass lxc_container_cache_path to lxc
|
||||
# templates as appropriate once the lxc update goes mainstream
|
||||
- name: Patch lxc-ubuntu cache path
|
||||
replace:
|
||||
dest: /usr/share/lxc/templates/lxc-ubuntu
|
||||
regexp: '\$LOCALSTATEDIR/cache/lxc'
|
||||
replace: "{{ lxc_container_cache_path }}"
|
||||
backup: yes
|
||||
tags:
|
||||
- lxc-cache-path
|
||||
|
56
tasks/lxc_install_apt.yml
Normal file
56
tasks/lxc_install_apt.yml
Normal file
@ -0,0 +1,56 @@
|
||||
---
|
||||
# Copyright 2016, Rackspace US, 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.
|
||||
|
||||
#TODO(evrardjp): Replace the next 2 tasks by a standard apt with cache
|
||||
#when https://github.com/ansible/ansible-modules-core/pull/1517 is merged
|
||||
#in 1.9.x or we move to 2.0 (if tested working)
|
||||
- name: Check apt last update file
|
||||
stat:
|
||||
path: /var/cache/apt
|
||||
register: apt_cache_stat
|
||||
tags:
|
||||
- lxc-apt-packages
|
||||
|
||||
- name: Update apt if needed
|
||||
apt:
|
||||
update_cache: yes
|
||||
when: "ansible_date_time.epoch|float - apt_cache_stat.stat.mtime > {{cache_timeout}}"
|
||||
tags:
|
||||
- lxc-apt-packages
|
||||
|
||||
- name: Install apt packages
|
||||
apt:
|
||||
pkg: "{{ item }}"
|
||||
state: present
|
||||
register: install_packages
|
||||
until: install_packages|success
|
||||
retries: 5
|
||||
delay: 2
|
||||
with_items: lxc_apt_packages
|
||||
tags:
|
||||
- lxc-apt-packages
|
||||
|
||||
# The functionality with changing the container cache has been added into the
|
||||
# upstream LXC templates with patch [ https://github.com/lxc/lxc/pull/558 ]
|
||||
# TODO: remove the below patch and pass lxc_container_cache_path to lxc
|
||||
# templates as appropriate once the lxc update goes mainstream
|
||||
- name: Patch lxc-ubuntu cache path
|
||||
replace:
|
||||
dest: /usr/share/lxc/templates/lxc-ubuntu
|
||||
regexp: '\$LOCALSTATEDIR/cache/lxc'
|
||||
replace: "{{ lxc_container_cache_path }}"
|
||||
backup: yes
|
||||
tags:
|
||||
- lxc-cache-path
|
@ -13,6 +13,15 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
- name: Gather variables for each operating system
|
||||
include_vars: "{{ item }}"
|
||||
with_first_found:
|
||||
- "{{ ansible_distribution | lower }}-{{ ansible_distribution_version | lower }}.yml"
|
||||
- "{{ ansible_distribution | lower }}.yml"
|
||||
- "{{ ansible_os_family | lower }}.yml"
|
||||
tags:
|
||||
- always
|
||||
|
||||
- include: lxc_pre_install.yml
|
||||
- include: lxc_install.yml
|
||||
- include: lxc_post_install.yml
|
||||
|
55
vars/ubuntu-14.04.yml
Normal file
55
vars/ubuntu-14.04.yml
Normal file
@ -0,0 +1,55 @@
|
||||
---
|
||||
# Copyright 2016, Rackspace US, 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.
|
||||
|
||||
## APT Cache Options
|
||||
cache_timeout: 600
|
||||
|
||||
# Container repos
|
||||
lxc_container_template_main_apt_repo: "https://mirror.rackspace.com/ubuntu"
|
||||
lxc_container_template_security_apt_repo: "https://mirror.rackspace.com/ubuntu"
|
||||
lxc_container_template_apt_components:
|
||||
- main
|
||||
- universe
|
||||
|
||||
# Default image to build from
|
||||
lxc_container_release: trusty
|
||||
lxc_container_user_name: ubuntu
|
||||
|
||||
# Required apt packages.
|
||||
lxc_apt_packages:
|
||||
- apparmor
|
||||
- apparmor-utils
|
||||
- bridge-utils
|
||||
- cgmanager
|
||||
- cgroup-lite
|
||||
- debootstrap
|
||||
- dnsmasq
|
||||
- git
|
||||
- irqbalance
|
||||
- language-pack-en
|
||||
- liblxc1
|
||||
- lxc
|
||||
- lxc-dev
|
||||
- lxc-templates
|
||||
- python-dev
|
||||
- python3-lxc
|
||||
|
||||
# Commands to run against cached LXC image
|
||||
lxc_cache_commands:
|
||||
- apt-get update
|
||||
- apt-get -y upgrade
|
||||
- apt-get -y install python2.7
|
||||
- rm -f /usr/bin/python
|
||||
- ln -s /usr/bin/python2.7 /usr/bin/python
|
Loading…
x
Reference in New Issue
Block a user