[debops.debops] Remove Ansible management

The role will now use the 'debops.ansible' role to install Ansible
instead of doing this directly.
parent bc1d3be0
......@@ -278,7 +278,7 @@ stages:
# --- d --- [[[2
'debops role':
<<: *test_role_1st_deps
<<: *test_role_2nd_deps
variables:
JANE_TEST_PLAY: '${DEBOPS_PLAYBOOKS}/service/debops.yml'
JANE_INVENTORY_GROUPS: 'debops_service_debops'
......
......@@ -24,7 +24,8 @@ Added
- New DebOps roles:
- :ref:`debops.ansible`: install Ansible on a Debian/Ubuntu host using
Ansible.
Ansible. The :ref:`debops.debops` role now uses the the new role to install
Ansible instead of doing it directly.
- :ref:`debops.apt_mark`: set install state of APT packages (manual/auto) or
specify that particular packages should be held in their current state.
......
......@@ -47,8 +47,9 @@ Debian
On older Debian releases, you should consider installing Ansible by creating
a ``.deb`` package from the official :command:`git` repository sources. You
can find a :command:`bootstrap-ansible.sh` script which can do this for you
automatically in the :ref:`debops.debops` Ansible role.
can find a :command:`bootstrap-ansible` script which can do this for you
automatically in the :ref:`debops.ansible` Ansible role :file:`files/`
subdirectory.
macOS
The ``debops`` Python package which contains scripts and modules used by the
......
......@@ -243,7 +243,7 @@ EOF
if [ -n "${ansible_from_devel}" ] ; then
jane notify install "Installing Ansible from GitHub..."
/vagrant/ansible/roles/debops.debops/files/script/bootstrap-ansible.sh "${ansible_from_devel}"
/vagrant/ansible/roles/debops.ansible/files/script/bootstrap-ansible "${ansible_from_devel}"
fi
jane notify install "Installing Ansible requirements via APT..."
......
......@@ -14,7 +14,10 @@
- role: debops.apt_preferences
tags: [ 'role::apt_preferences' ]
apt_preferences__dependent_list:
- '{{ debops__apt_preferences__dependent_list }}'
- '{{ ansible__apt_preferences__dependent_list }}'
- role: debops.ansible
tags: [ 'role::ansible' ]
- role: debops.debops
tags: [ 'role::debops' ]
......@@ -16,14 +16,6 @@
# List of APT packages required by DebOps on Ansible Controller.
debops__base_packages: [ 'python-netaddr', 'python-passlib', 'uuid-runtime', 'python-setuptools' ]
# ]]]
# .. envvar:: debops__ansible_packages [[[
#
# Ansible should be installed using APT, but available packages might be too
# old. If you want to install Ansible by other means, you can disable the APT
# package installation here.
debops__ansible_packages: [ 'ansible' ]
# ]]]
# .. envvar:: debops__packages [[[
#
......@@ -37,43 +29,6 @@ debops__packages: []
debops__pip_packages: [ 'debops' ]
# ]]]
# ]]]
# Ansible git source installation [[[
# -----------------------------------
# .. envvar:: debops__ansible_git [[[
#
# If enabled and ``True``, role will clone the Ansible source from GitHub,
# build the Ansible Debian package and install it. On repeated runs, Ansible
# will be automatically updated on the selected :command:`git` branch.
debops__ansible_git: False
# ]]]
# .. envvar:: debops__ansible_git_branch [[[
#
# Specify the :command:`git` branch to use for installing Ansible from source. By
# default, current development branch is used.
debops__ansible_git_branch: 'devel'
# ]]]
# .. envvar:: debops__ansible_git_build_dir [[[
#
# Path where Ansible :command:`git` source is stored and where builds happen.
debops__ansible_git_build_dir: '{{ (ansible_local.root.src
if (ansible_local|d() and ansible_local.root|d() and
ansible_local.root.src|d())
else "/usr/local/src") + "/debops" }}'
# ]]]
# .. envvar:: debops__ansible_git_become_user [[[
#
# The role will switch to the admin user account to perform the build. The
# build script needs :command:`sudo` access to install the built ``*.deb`` package,
# which the admin account should have.
debops__ansible_git_become_user: '{{ ansible_user
if ansible_user|d()
else lookup("env", "USER") }}'
# ]]]
# ]]]
# Playbook and role installation [[[
# ----------------------------------
......@@ -138,16 +93,4 @@ debops__project_git_repo: ''
debops__project_name: ''
# ]]]
# ]]]
# Configuration for other Ansible roles [[[
# -----------------------------------------
# .. envvar:: debops__apt_preferences__dependent_list [[[
#
# Configuration for the :ref:`debops.apt_preferences`.
debops__apt_preferences__dependent_list:
- package: 'ansible'
backports: [ 'jessie' ]
reason: 'Use Ansible from Debian Backports'
# ]]]
# ]]]
# ]]]
#!/bin/bash
# bootstrap-ansible.sh: download and build Ansible on Debian/Ubuntu host
# Copyright (C) 2014-2017 Maciej Delmanowski <drybjed@gmail.com>
# Copyright (C) 2014-2017 DebOps https://debops.org/
# This program is free software; you can redistribute
# it and/or modify it under the terms of the
# GNU General Public License as published by the Free
# Software Foundation; either version 3 of the License,
# or (at your option) any later version.
#
# This program is distributed in the hope that it will
# be useful, but WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU General Public
# License for more details.
#
# You should have received a copy of the GNU General
# Public License along with this program; if not,
# write to the Free Software Foundation, Inc., 59
# Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# An on-line copy of the GNU General Public License can
# be downloaded from the FSF web page at:
# https://www.gnu.org/copyleft/gpl.html
# Usage: ./bootstrap-ansible.sh [branch] [build_directory]
set -e
install_ansible_requirements () {
sudo apt-get --no-install-recommends -qq -y install git devscripts \
python-paramiko python-yaml python-jinja2 python-httplib2 \
cdbs debhelper dpkg-dev fakeroot sshpass python-nose python-passlib \
python-setuptools asciidoc xmlto build-essential python-sphinx \
python-crypto lsb-release python-packaging
}
build_ansible_deb () {
# Build Debian package
if [ -n "$(grep 'local_deb' Makefile || true)" ] ; then
LANG=C make local_deb
else
LANG=C make deb
fi
# Check if .deb package with new method is present
if [ -n "$(find deb-build/unstable/ -name "ansible_*_all.deb" 2>/dev/null)" ]; then
sudo dpkg -i deb-build/unstable/ansible_*_all.deb
# Otherwise, look for package generated with old method
elif [ -n "$(find .. -name "ansible_*_all.deb" 2>/dev/null)" ]; then
sudo dpkg -i ../ansible_*_all.deb
fi
}
bootstrap_ansible_deb () {
local ansible_branch
local build_dir
local ansible_git_repo
local ansible_source_dir
ansible_branch="${1:-devel}"
build_dir="${2:-$(mktemp -d)}"
ansible_git_repo="${3:-https://github.com/ansible/ansible}"
ansible_source_dir="ansible"
if [ ! -d "${build_dir}" ] ; then
mkdir -p "${build_dir}"
fi
cd "${build_dir}"
if [ -d "${ansible_source_dir}" ] ; then
cd "${ansible_source_dir}"
local old_git_checkout
local current_branch_name
local current_branch_name
local current_branch_name
old_git_checkout="$(git rev-parse HEAD)"
current_branch_name="$(git symbolic-ref HEAD 2>/dev/null)" ||
current_branch_name="(unnamed branch)" # detached HEAD
current_branch_name=${current_branch_name##refs/heads/}
if [ "${current_branch_name}" != "${ansible_branch}" ] ; then
git checkout "${ansible_branch}"
fi
git pull --quiet
git submodule update
local current_git_checkout
current_git_checkout="$(git rev-parse HEAD)"
if [ "${old_git_checkout}" != "${current_git_checkout}" ] ; then
build_ansible_deb
fi
else
install_ansible_requirements
git clone --branch "${ansible_branch}" --recursive "${ansible_git_repo}" "${ansible_source_dir}"
cd "${ansible_source_dir}"
build_ansible_deb
fi
}
ansible_branch="${1:-devel}"
build_dir="${2:-$(mktemp -d)}"
bootstrap_ansible_deb "${ansible_branch}" "${build_dir}"
---
- name: Make sure Ansible build directory exists
file:
path: '{{ debops__ansible_git_build_dir }}'
state: 'directory'
owner: '{{ debops__ansible_git_become_user }}'
group: 'root'
mode: '0755'
when: debops__ansible_git|bool
- name: Bootstrap Ansible from source
script: 'script/bootstrap-ansible.sh "{{ debops__ansible_git_branch }}" "{{ debops__ansible_git_build_dir }}"'
become_user: '{{ debops__ansible_git_become_user }}'
register: debops__register_bootstrap
when: debops__ansible_git|bool
changed_when: debops__register_bootstrap.stdout != ""
- name: Install required packages
apt:
name: '{{ item }}'
......@@ -24,7 +8,6 @@
with_flattened:
- [ 'git', 'python-pip' ]
- '{{ debops__base_packages }}'
- '{{ debops__ansible_packages }}'
- '{{ debops__packages }}'
when: item|d()
......
......@@ -7,19 +7,6 @@ Getting started
Initial configuration
---------------------
This role installs the :command:`ansible` APT package for Ansible support. However, the
package from official distribution repositories might be outdated or might not
even exist (yet). Because of that, if you need to, you can disable :command:`ansible`
package installation using the :envvar:`debops__ansible_packages` variable.
An alternative is to build stable Ansible ``.deb`` package on a spare build
host and provide it via a local APT repository. That way, the role will
automatically install the correct Ansible version and will be ready to go.
Another alternative is to disable APT Ansible package and enable installation
from PyPI alongside ``debops`` package. However, APT method is preferred, since
it automatically installs all required APT packages.
By default the ``debops.debops`` role will install the DebOps playbooks and roles
from GitHub in the background, using either the ``batch`` command from the ``at``
package, or if the former is not available, ``async`` Ansible task. Keep in mind
......
......@@ -26,6 +26,13 @@ X.509 certificate changes
redefined it in the Ansible inventory, you might want to update your version
to include the new SubjectAltName entry.
Role changes
~~~~~~~~~~~~
- The :ref:`debops.debops` role now uses the :ref:`debops.ansible` role to
install Ansible instead of doing it by itself. The relevant code has been
removed, see the :ref:`debops.ansible` role documentation for new variables.
Inventory variable changes
~~~~~~~~~~~~~~~~~~~~~~~~~~
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment