From 886fe01edb01b9f21e3576f50711738687b236d9 Mon Sep 17 00:00:00 2001 From: Kevin Carter Date: Tue, 21 Apr 2015 18:02:50 -0500 Subject: [PATCH] Add release pinning to galera roles As both Ubuntu and the MariaDB repositories carry packages with the same names, apt package pinning is required to ensure that the packages we install come from the right repository. This patch adds a pinning preference file to ensure that the packages we install come from the MariaDB repository. Due to the OpenStack CI images having conflicting packages installed in the base image, this patch also includes the removal of these packages during the AIO bootstrap to ensure that the deployment succeeds. For environments where the same two packages are installed on the hosts prior to the deployment of os-ansible-deployment, they would need to ensure that the packages are removed first. This has been seen in environments where monitoring tooling has installed the packages as a dependancy. Closes-Bug: #1446772 Change-Id: I5ad0b9010e49832c4f866c0b141e1c035d5f9268 --- playbooks/roles/galera_client/defaults/main.yml | 6 ++++-- .../tasks/galera_client_pre_install.yml | 15 ++++++++++++--- .../templates/galera_client_pin.pref.j2 | 5 +++++ playbooks/roles/galera_server/defaults/main.yml | 6 ++++-- .../galera_server/tasks/galera_pre_install.yml | 15 ++++++++++++--- .../galera_server/templates/galera_pin.pref.j2 | 5 +++++ scripts/bootstrap-aio.sh | 7 ++++++- 7 files changed, 48 insertions(+), 11 deletions(-) create mode 100644 playbooks/roles/galera_client/templates/galera_client_pin.pref.j2 create mode 100644 playbooks/roles/galera_server/templates/galera_pin.pref.j2 diff --git a/playbooks/roles/galera_client/defaults/main.yml b/playbooks/roles/galera_client/defaults/main.yml index 896b7e35ca..20f1d007ae 100644 --- a/playbooks/roles/galera_client/defaults/main.yml +++ b/playbooks/roles/galera_client/defaults/main.yml @@ -25,8 +25,10 @@ galera_client_gpg_keys: hash_id: '0xcbcb082a1bb943db' # Repositories -galera_client_apt_repos: - - { repo: "deb http://mirror.rackspace.com/mariadb/repo/5.5/ubuntu {{ ansible_distribution_release }} main", state: "present" } +galera_client_apt_repo_url: "http://mirror.rackspace.com/mariadb/repo/5.5/ubuntu" +galera_client_apt_repo: + repo: "deb {{ galera_client_apt_repo_url }} {{ ansible_distribution_release }} main" + state: "present" galera_client_apt_packages: - libmariadbclient-dev diff --git a/playbooks/roles/galera_client/tasks/galera_client_pre_install.yml b/playbooks/roles/galera_client/tasks/galera_client_pre_install.yml index 5a488ac0a4..aa9b76619e 100644 --- a/playbooks/roles/galera_client/tasks/galera_client_pre_install.yml +++ b/playbooks/roles/galera_client/tasks/galera_client_pre_install.yml @@ -40,11 +40,20 @@ tags: - galera-client-apt-keys +- name: Drop galera repo pin + template: + src: "galera_client_pin.pref.j2" + dest: "/etc/apt/preferences.d/galera_client_pin.pref" + owner: "root" + group: "root" + mode: "0644" + tags: + - galera-client-repo-pin + - name: Add galera repo(s) apt_repository: - repo: "{{ item.repo }}" - state: "{{ item.state }}" - with_items: galera_client_apt_repos + repo: "{{ galera_client_apt_repo.repo }}" + state: "{{ galera_client_apt_repo.state }}" register: add_repos until: add_repos|success retries: 5 diff --git a/playbooks/roles/galera_client/templates/galera_client_pin.pref.j2 b/playbooks/roles/galera_client/templates/galera_client_pin.pref.j2 new file mode 100644 index 0000000000..0d2a6e5c22 --- /dev/null +++ b/playbooks/roles/galera_client/templates/galera_client_pin.pref.j2 @@ -0,0 +1,5 @@ +# {{ ansible_managed }} + +Package: * +Pin: release o=MariaDB +Pin-Priority: 1001 diff --git a/playbooks/roles/galera_server/defaults/main.yml b/playbooks/roles/galera_server/defaults/main.yml index 6dfe4a97e1..924f49e0af 100644 --- a/playbooks/roles/galera_server/defaults/main.yml +++ b/playbooks/roles/galera_server/defaults/main.yml @@ -52,8 +52,10 @@ galera_gpg_keys: hash_id: '0xcbcb082a1bb943db' # Repositories -galera_apt_repos: - - { repo: "deb http://mirror.rackspace.com/mariadb/repo/5.5/ubuntu {{ ansible_distribution_release }} main", state: "present" } +galera_apt_repo_url: "http://mirror.rackspace.com/mariadb/repo/5.5/ubuntu" +galera_apt_repo: + repo: "deb {{ galera_apt_repo_url }} {{ ansible_distribution_release }} main" + state: "present" galera_pip_packages: - MySQL-python diff --git a/playbooks/roles/galera_server/tasks/galera_pre_install.yml b/playbooks/roles/galera_server/tasks/galera_pre_install.yml index d7267e8e11..2d816d90d2 100644 --- a/playbooks/roles/galera_server/tasks/galera_pre_install.yml +++ b/playbooks/roles/galera_server/tasks/galera_pre_install.yml @@ -55,11 +55,20 @@ tags: - galera-apt-keys +- name: Drop galera repo pin + template: + src: "galera_pin.pref.j2" + dest: "/etc/apt/preferences.d/galera_pin.pref" + owner: "root" + group: "root" + mode: "0644" + tags: + - galera-repo-pin + - name: Add galera repo(s) apt_repository: - repo: "{{ item.repo }}" - state: "{{ item.state }}" - with_items: galera_apt_repos + repo: "{{ galera_apt_repo.repo }}" + state: "{{ galera_apt_repo.state }}" register: add_repos until: add_repos|success retries: 5 diff --git a/playbooks/roles/galera_server/templates/galera_pin.pref.j2 b/playbooks/roles/galera_server/templates/galera_pin.pref.j2 new file mode 100644 index 0000000000..0d2a6e5c22 --- /dev/null +++ b/playbooks/roles/galera_server/templates/galera_pin.pref.j2 @@ -0,0 +1,5 @@ +# {{ ansible_managed }} + +Package: * +Pin: release o=MariaDB +Pin-Priority: 1001 diff --git a/scripts/bootstrap-aio.sh b/scripts/bootstrap-aio.sh index 18ddcb7f74..073c23a081 100755 --- a/scripts/bootstrap-aio.sh +++ b/scripts/bootstrap-aio.sh @@ -86,8 +86,13 @@ if [ ! "$(grep -e '^nameserver 8.8.8.8' -e '^nameserver 8.8.4.4' /etc/resolv.con echo -e '\n# Adding google name servers\nnameserver 8.8.8.8\nnameserver 8.8.4.4' | tee -a /etc/resolv.conf fi -# Update the package cache and install required packages +# Update the package cache apt-get update + +# Remove known conflicting packages in the base image +apt-get purge -y libmysqlclient18 mysql-common + +# Install required packages apt-get install -y python-dev \ python2.7 \ build-essential \