From 0c5cd7d681f274c9e536e536e4e3097b5664e1e2 Mon Sep 17 00:00:00 2001 From: Adrien Waksberg Date: Sat, 18 May 2019 12:26:37 +0200 Subject: [PATCH] feat: add official repository --- .kitchen.yml | 2 +- .travis.yml | 3 +-- CHANGELOG.md | 6 +++++- README.md | 18 +++++++++++------- defaults/main.yml | 6 ++++++ tasks/main.yml | 5 ++++- tasks/repo.yml | 11 +++++++++++ .../default/serverspec/default_spec.rb | 2 +- 8 files changed, 40 insertions(+), 13 deletions(-) create mode 100644 tasks/repo.yml diff --git a/.kitchen.yml b/.kitchen.yml index 7a16e14..7efd83c 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -17,7 +17,7 @@ provisioner: platforms: - name: debian-9 driver_config: - image: "nishiki/debian9:ansible-<%= ENV['ANSIBLE_VERSION'] ? ENV['ANSIBLE_VERSION'] : '2.7' %>" + image: "nishiki/debian9:ansible-<%= ENV['ANSIBLE_VERSION'] ? ENV['ANSIBLE_VERSION'] : '2.8' %>" command: /bin/systemd volume: - /sys/fs/cgroup:/sys/fs/cgroup:ro diff --git a/.travis.yml b/.travis.yml index 726f3cb..1fc9885 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,8 +3,7 @@ sudo: required language: ruby env: - - ANSIBLE_VERSION=2.6 - - ANSIBLE_VERSION=2.7 + - ANSIBLE_VERSION=2.8 services: - docker diff --git a/CHANGELOG.md b/CHANGELOG.md index f72b04a..386c30b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,14 +4,18 @@ This project adheres to [Semantic Versioning](http://semver.org/). Which is based on [Keep A Changelog](http://keepachangelog.com/) ## [Unreleased] -- breaking: remove support for ansible 2.5 + +- breaking: remove support for ansible < 2.8 +- feat: add official repository - feat: remove unused users in init - feat: install database if datadir doesn't exist ## [v1.0.1] - 2019-03-16 + - fix: add client-server option in default configuration - fix: install python-mysqldb package - test: add tests with travis-ci ## [v1.0.0] - 2019-02-23 + - first version diff --git a/README.md b/README.md index bad6670..0b93df1 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # Ansible role: MariaDB + [![Version](https://img.shields.io/badge/latest_version-1.0.1-green.svg)](https://git.yaegashi.fr/nishiki/ansible-role-mariadb/releases) [![Build Status](https://travis-ci.org/nishiki/ansible-role-mariadb.svg?branch=master)](https://travis-ci.org/nishiki/ansible-role-mariadb) [![License](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](https://git.yaegashi.fr/nishiki/ansible-role-mariadb/src/branch/master/LICENSE) @@ -12,11 +13,13 @@ Install and configure MariaDB ## Role variables -- `mariadb_user` - login to connect on mariadb (default: `root`) -- `mariadb_password` - password to connect on mariadb (default: `secret`) -- `mariadb_master` - the server is master (default: `no`) -- `mariadb_autorestart` - restart mariadb when the config change (default: `no`) -- `mariadb_users` - array with the users to manage +* `mariadb_use_official_repository` - use the official repository (default: `yes`) +* `mariadb_branch` - the branch version to install (default: `10.3`) +* `mariadb_user` - login to connect on mariadb (default: `root`) +* `mariadb_password` - password to connect on mariadb (default: `secret`) +* `mariadb_master` - the server is master (default: `no`) +* `mariadb_autorestart` - restart mariadb when the config change (default: `no`) +* `mariadb_users` - array with the users to manage ``` - name: johndoe @@ -26,14 +29,14 @@ Install and configure MariaDB state: present ``` -- `mariadb_databases` - array with the databases to manage +* `mariadb_databases` - array with the databases to manage ``` - name: superprogram state: present ``` -- `mariadb_config` - hash with mariadb configuration +* `mariadb_config` - hash with mariadb configuration ``` mysqld: @@ -50,6 +53,7 @@ Install and configure MariaDB ``` ## Development + ### Test syntax with yamllint * install `python` and `python-pip` diff --git a/defaults/main.yml b/defaults/main.yml index 455ebfa..6f86c32 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,4 +1,10 @@ --- +mariadb_use_official_repository: yes +mariadb_branch: 10.3 +mariadb_repository: | + deb http://mariadb.mirrors.ovh.net/MariaDB/repo/{{ mariadb_branch }}/debian {{ ansible_distribution_release }} main +mariadb_repository_key_id: '0xF1656F24C74CD1D8' +mariadb_repository_key_server: keyserver.ubuntu.com mariadb_user: root mariadb_password: secret mariadb_master: no diff --git a/tasks/main.yml b/tasks/main.yml index 1aae5b7..fc6d4bc 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,4 +1,7 @@ --- +- import_tasks: repo.yml + when: mariadb_use_official_repository|bool + - name: install package package: name: '{{ packages }}' @@ -14,7 +17,7 @@ - name: copy configuration file template: src: my.cnf.j2 - dest: /etc/mysql/mariadb.cnf + dest: /etc/mysql/my.cnf owner: root group: root mode: 0644 diff --git a/tasks/repo.yml b/tasks/repo.yml new file mode 100644 index 0000000..f83d8ff --- /dev/null +++ b/tasks/repo.yml @@ -0,0 +1,11 @@ +--- +- name: add gpg key for mariadb repository + apt_key: + keyserver: '{{ mariadb_repository_key_server }}' + id: '{{ mariadb_repository_key_id }}' + tags: mariadb + +- name: add official repo + apt_repository: + repo: '{{ mariadb_repository }}' + tags: mariadb diff --git a/test/integration/default/serverspec/default_spec.rb b/test/integration/default/serverspec/default_spec.rb index 38492d4..567db25 100644 --- a/test/integration/default/serverspec/default_spec.rb +++ b/test/integration/default/serverspec/default_spec.rb @@ -23,7 +23,7 @@ describe file('/opt/mariadb') do it { should be_grouped_into 'root' } end -describe file('/etc/mysql/mariadb.cnf') do +describe file('/etc/mysql/my.cnf') do it { should be_file } it { should be_mode 644 } it { should be_owned_by 'root' }