From 24c3bf69c3d1ae7cb329cdbba5749a3de2be375d Mon Sep 17 00:00:00 2001 From: Mischa ter Smitten Date: Thu, 28 Jan 2021 15:34:40 +0100 Subject: [PATCH 1/2] Make use of github actions --- .ansible-lint | 5 +-- .github/workflows/ci.yml | 80 +++++++++++++++++++++++++++++++++++ .github/workflows/release.yml | 20 +++++++++ .travis.yml => .travis.yml_ | 0 .yamllint | 15 +++++++ Dockerfile | 2 +- README.md | 6 ++- Vagrantfile | 26 +++--------- defaults/main.yml | 2 +- meta/main.yml | 4 +- molecule/default/converge.yml | 6 +++ molecule/default/molecule.yml | 19 +++++++++ molecule/default/prepare.yml | 5 +++ molecule/default/verify.yml | 5 +++ tasks/repository.yml | 6 +-- vars/main.yml | 8 +++- 16 files changed, 173 insertions(+), 36 deletions(-) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/release.yml rename .travis.yml => .travis.yml_ (100%) create mode 100644 .yamllint create mode 100644 molecule/default/converge.yml create mode 100644 molecule/default/molecule.yml create mode 100644 molecule/default/prepare.yml create mode 100644 molecule/default/verify.yml diff --git a/.ansible-lint b/.ansible-lint index a729cc7..c099c60 100644 --- a/.ansible-lint +++ b/.ansible-lint @@ -1,3 +1,2 @@ -skip_list: - - '204' - - '306' +warn_list: + - '106' diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..c5bd6e1 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,80 @@ +--- +name: CI +'on': + pull_request: + push: + branches: + - master + schedule: + - cron: '30 1 * * 3' + +jobs: + + lint: + name: Lint + runs-on: ubuntu-latest + steps: + - name: Check out the codebase + uses: actions/checkout@v2 + + - name: Set up Python 3 + uses: actions/setup-python@v2 + with: + python-version: '3.x' + + - name: Install test dependencies + run: pip install yamllint ansible-lint + + - name: Lint code + run: | + yamllint . + ansible-lint + + molecule: + name: Molecule + runs-on: ubuntu-latest + defaults: + run: + working-directory: "${{ github.repository }}" + needs: + - lint + strategy: + fail-fast: false + matrix: + include: + - distro: debian8 + - distro: debian9 + - distro: debian10 + - distro: ubuntu1604 + ansible-version: '>=2.8, <2.9' + - distro: ubuntu1604 + ansible-version: '>=2.9, <2.10' + - distro: ubuntu1604 + ansible-version: '>=2.10, <2.11' + - distro: ubuntu1604 + - distro: ubuntu1804 + - distro: ubuntu2004 + + steps: + - name: Check out the codebase + uses: actions/checkout@v2 + with: + path: "${{ github.repository }}" + + - name: Set up Python 3 + uses: actions/setup-python@v2 + with: + python-version: '3.x' + + - name: Install test dependencies + run: pip install 'ansible${{ matrix.ansible-version }}' molecule[docker] docker + + - name: Run Molecule tests + run: | + molecule test + env: + ANSIBLE_FORCE_COLOR: '1' + ANSIBLE_VERBOSITY: '2' + MOLECULE_DEBUG: '1' + MOLECULE_DISTRO: "${{ matrix.distro }}" + PY_COLORS: '1' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..2354e68 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,20 @@ +--- +name: Release +'on': + push: + tags: + - '*' + +jobs: + + release: + name: Release + runs-on: ubuntu-latest + steps: + - name: Check out the codebase + uses: actions/checkout@v2 + + - name: Publish to Galaxy + uses: robertdebock/galaxy-action@1.1.0 + with: + galaxy_api_key: ${{ secrets.GALAXY_API_KEY }} diff --git a/.travis.yml b/.travis.yml_ similarity index 100% rename from .travis.yml rename to .travis.yml_ diff --git a/.yamllint b/.yamllint new file mode 100644 index 0000000..894450c --- /dev/null +++ b/.yamllint @@ -0,0 +1,15 @@ +--- +extends: default + +rules: + braces: + max-spaces-inside: 1 + level: error + brackets: + max-spaces-inside: 1 + level: error + line-length: disable + truthy: disable + +ignore: | + .tox/ diff --git a/Dockerfile b/Dockerfile index 78650c6..fc89ab2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,7 +11,7 @@ RUN rm -rf $HOME/.cache # ansible RUN DEBIAN_FRONTEND=noninteractive apt-get install -y gcc libffi-dev libssl-dev && \ apt-get clean -RUN pip install ansible==2.9.14 +RUN pip install ansible==2.9.15 RUN rm -rf $HOME/.cache # provision diff --git a/README.md b/README.md index d08e61c..c0f1079 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ## percona-server -[![Build Status](https://travis-ci.org/Oefenweb/ansible-percona-server.svg?branch=master)](https://travis-ci.org/Oefenweb/ansible-percona-server) +[![Build Status](https://travis-ci.org/Oefenweb/ansible-percona-server.svg?branch=master)](https://travis-ci.org/Oefenweb/ansible-percona-server) [![Ansible Galaxy](http://img.shields.io/badge/ansible--galaxy-percona--server-blue.svg)](https://galaxy.ansible.com/Oefenweb/percona-server) Set up a [percona-server](https://www.percona.com/software/mysql-database/percona-server) server in Debian-like systems. @@ -9,12 +9,14 @@ Set up a [percona-server](https://www.percona.com/software/mysql-database/percon * `python-mysqldb(2|3)` (will be installed) * `tee` (will not be installed) +* `software-properties-common` (will be installed) +* `dirmngr` (will be installed) #### Variables ##### General -* `percona_server_version`: [default: `5.6`]: Version to install (e.g. `5.6`) +* `percona_server_version`: [default: `5.7`]: Version to install (e.g. `5.6`) * `percona_server_root_password`: [default: `+eswuw9uthUteFreyAqu`]: Root password **Make sure to change!** * `percona_server_install`: [`['xtrabackup']`]: Additional packages to install diff --git a/Vagrantfile b/Vagrantfile index 3517233..a0182a0 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -4,40 +4,26 @@ role = File.basename(File.expand_path(File.dirname(__FILE__))) boxes = [ - { - :name => "ubuntu-1204", - :box => "bento/ubuntu-12.04", - :ip => '10.0.0.11', - :cpu => "50", - :ram => "256" - }, - { - :name => "ubuntu-1404", - :box => "bento/ubuntu-14.04", - :ip => '10.0.0.12', - :cpu => "50", - :ram => "256" - }, { :name => "ubuntu-1604", :box => "bento/ubuntu-16.04", - :ip => '10.0.0.13', + :ip => '10.0.0.12', :cpu => "50", :ram => "256" }, { :name => "ubuntu-1804", :box => "bento/ubuntu-18.04", - :ip => '10.0.0.14', + :ip => '10.0.0.13', :cpu => "50", :ram => "384" }, { - :name => "debian-7", - :box => "bento/debian-7", - :ip => '10.0.0.15', + :name => "ubuntu-2004", + :box => "bento/ubuntu-20.04", + :ip => '10.0.0.14', :cpu => "50", - :ram => "256" + :ram => "384" }, { :name => "debian-8", diff --git a/defaults/main.yml b/defaults/main.yml index 1988056..d6633c6 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,6 +1,6 @@ # defaults file for percona-server --- -percona_server_version: 5.6 +percona_server_version: 5.7 percona_server_root_password: '+eswuw9uthUteFreyAqu' diff --git a/meta/main.yml b/meta/main.yml index 685eba6..f0b33ff 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -10,13 +10,11 @@ galaxy_info: platforms: - name: Ubuntu versions: - - precise - - trusty - xenial - bionic + - focal - name: Debian versions: - - wheezy - jessie - stretch - buster diff --git a/molecule/default/converge.yml b/molecule/default/converge.yml new file mode 100644 index 0000000..be762b2 --- /dev/null +++ b/molecule/default/converge.yml @@ -0,0 +1,6 @@ +--- +- name: Converge + hosts: all + become: true + roles: + - ../../../ diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml new file mode 100644 index 0000000..fbb7120 --- /dev/null +++ b/molecule/default/molecule.yml @@ -0,0 +1,19 @@ +--- +dependency: + name: galaxy +driver: + name: docker +platforms: + - name: instance + image: "geerlingguy/docker-${MOLECULE_DISTRO:-ubuntu1604}-ansible:latest" + command: ${MOLECULE_DOCKER_COMMAND:-""} + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + privileged: true + pre_build_image: true +provisioner: + name: ansible + playbooks: + prepare: prepare.yml + converge: converge.yml + verify: verify.yml diff --git a/molecule/default/prepare.yml b/molecule/default/prepare.yml new file mode 100644 index 0000000..9a6673d --- /dev/null +++ b/molecule/default/prepare.yml @@ -0,0 +1,5 @@ +--- +- name: Prepare + hosts: all + become: true + tasks: [] diff --git a/molecule/default/verify.yml b/molecule/default/verify.yml new file mode 100644 index 0000000..44debad --- /dev/null +++ b/molecule/default/verify.yml @@ -0,0 +1,5 @@ +--- +- name: Verify + hosts: all + become: true + tasks: [] diff --git a/tasks/repository.yml b/tasks/repository.yml index 486a03e..192faf7 100644 --- a/tasks/repository.yml +++ b/tasks/repository.yml @@ -1,13 +1,11 @@ # tasks file for percona-server --- -- name: repository | install | dependencies +- name: repository | install | dependencies (pre) apt: - name: - - dirmngr + name: "{{ percona_server_dependencies_pre }}" state: "{{ apt_install_state | default('latest') }}" update_cache: true cache_valid_time: "{{ apt_update_cache_valid_time | default(3600) }}" - when: ansible_distribution == 'Debian' and ansible_distribution_version is version('9', '>=') tags: - percona-server-repository-install - percona-server-repository-install-dependencies diff --git a/vars/main.yml b/vars/main.yml index ca7cd81..4ce1325 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -7,10 +7,10 @@ percona_server_versions_supported: percona_server_repositories: - type: deb - url: "http://repo.percona.com/apt {{ ansible_lsb.codename }}" + url: "http://repo.percona.com/apt {{ ansible_distribution_release }}" component: main - type: deb-src - url: "http://repo.percona.com/apt {{ ansible_lsb.codename }}" + url: "http://repo.percona.com/apt {{ ansible_distribution_release }}" component: main percona_server_debconf_selections: @@ -32,6 +32,10 @@ percona_server_debconf_selections: value: "{{ percona_server_root_password }}" vtype: password +percona_server_dependencies_pre: + - software-properties-common + - dirmngr + percona_server_dependencies: - "percona-server-client-{{ percona_server_version }}" - "percona-server-server-{{ percona_server_version }}" From 566033d8dd711488ba73870d5f6914b2926f6470 Mon Sep 17 00:00:00 2001 From: Mischa ter Smitten Date: Fri, 29 Jan 2021 00:22:11 +0100 Subject: [PATCH 2/2] Cs fixes --- .ansible-lint | 2 + .github/workflows/ci.yml | 1 + .travis.yml_ | 84 ---------------------------------------- README.md | 2 +- defaults/main.yml | 2 +- tasks/configure.yml | 42 ++++++++++---------- tasks/ib-logfile.yml | 56 +++++++++++++-------------- tests/vagrant.yml | 2 - 8 files changed, 54 insertions(+), 137 deletions(-) delete mode 100644 .travis.yml_ diff --git a/.ansible-lint b/.ansible-lint index c099c60..7a85cb6 100644 --- a/.ansible-lint +++ b/.ansible-lint @@ -1,2 +1,4 @@ warn_list: - '106' + - '204' + - '306' diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c5bd6e1..73f127a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,6 +43,7 @@ jobs: matrix: include: - distro: debian8 + ansible-version: '<2.10' - distro: debian9 - distro: debian10 - distro: ubuntu1604 diff --git a/.travis.yml_ b/.travis.yml_ deleted file mode 100644 index b586537..0000000 --- a/.travis.yml_ +++ /dev/null @@ -1,84 +0,0 @@ ---- -sudo: required -dist: xenial - -language: python -python: - - "2.7" - - "3.5" - -env: - - ANSIBLE_VERSION=latest - - ANSIBLE_VERSION=2.10.2 - - ANSIBLE_VERSION=2.10.1 - - ANSIBLE_VERSION=2.10.0 - - ANSIBLE_VERSION=2.9.14 - - ANSIBLE_VERSION=2.9.13 - - ANSIBLE_VERSION=2.9.12 - - ANSIBLE_VERSION=2.9.11 - - ANSIBLE_VERSION=2.9.10 - - ANSIBLE_VERSION=2.9.9 - - ANSIBLE_VERSION=2.9.8 - - ANSIBLE_VERSION=2.9.7 - - ANSIBLE_VERSION=2.9.6 - - ANSIBLE_VERSION=2.9.5 - - ANSIBLE_VERSION=2.9.4 - - ANSIBLE_VERSION=2.9.3 - - ANSIBLE_VERSION=2.9.2 - - ANSIBLE_VERSION=2.9.1 - - ANSIBLE_VERSION=2.9.0 - - ANSIBLE_VERSION=2.8.16 - - ANSIBLE_VERSION=2.8.15 - - ANSIBLE_VERSION=2.8.14 - - ANSIBLE_VERSION=2.8.13 - - ANSIBLE_VERSION=2.8.12 - - ANSIBLE_VERSION=2.8.11 - - ANSIBLE_VERSION=2.8.10 - - ANSIBLE_VERSION=2.8.9 - - ANSIBLE_VERSION=2.8.8 - - ANSIBLE_VERSION=2.8.7 - - ANSIBLE_VERSION=2.8.6 - - ANSIBLE_VERSION=2.8.5 - - ANSIBLE_VERSION=2.8.4 - - ANSIBLE_VERSION=2.8.3 - - ANSIBLE_VERSION=2.8.2 - - ANSIBLE_VERSION=2.8.1 - - ANSIBLE_VERSION=2.8.0 - -branches: - only: - - master - -before_install: - - sudo apt-get update -qq - - # Remove mysql-* - - sudo apt-get remove --purge --yes 'mysql-*' - -install: - # Install Ansible. - - if [ "$ANSIBLE_VERSION" = "latest" ]; then pip install ansible; else pip install ansible==$ANSIBLE_VERSION; fi - - if [ "$ANSIBLE_VERSION" = "latest" ]; then pip install ansible-lint; fi - -script: - # Check the role/playbook's syntax. - - ansible-playbook -i tests/inventory tests/test.yml --syntax-check - - # Run the role/playbook with ansible-playbook. - - ansible-playbook -i tests/inventory tests/test.yml -vvvv - - # Run the role/playbook again, checking to make sure it's idempotent. - - > - ansible-playbook -i tests/inventory tests/test.yml - | grep -q 'changed=0.*failed=0' - && (echo 'Idempotence test: pass' && exit 0) - || (echo 'Idempotence test: fail' && exit 1) - - - if [ "$ANSIBLE_VERSION" = "latest" ]; then ansible-lint tests/test.yml; fi - -notifications: - email: false - webhooks: https://galaxy.ansible.com/api/v1/notifications/ - slack: - rooms: - secure: "S20v9/HBge3kboJXgNm74eKZvoDufD+ylnhmapHxsSB9KHGVaBP/WZXs8nEmpsPA2IUhB6fAgkVn9glxO7BW5qiuFIEUJecrPoeXQOJRad7AO4ODOmxOYZ9s2n+ABXx52izKNXvNCm0HxivrnyF7LCV6RmO2PZz8YPkTGKGD/L0QofkUMDQEswhv4DVTc1fgAqFxlTLRVSQoJfgX/MaZ5CTpIY84udIxbwJ7bI1FNll2HX21rfYlXflk8gJakPRbAKtzXrPEXRzDHXIzIRkr/VuziucIHSNcIgD3Fjg6azOah3bJI1OcvPD1cNnDTudqDdKWCzDtH9TK9elvWbXVFyNi+rOigwaMclnZRBEqKd+feM+pB7aZjhaZ4qIXTgm8NlmGqhKVv32ZmCWp97PobF5GEjkohh3DB7RaEeKKeYD2xdc/idqPCqdCe0yEqXI/dPihaV4B6630av2WzMUSiNs3VN1u1TemvMpFY5Ee7wWRK0md3JTG/x2Xxv/wd5bSh4q4KZ26FQUz8a9jcYeKa8SkSb35LBP1jwpqECoJmdUcCbRNoh2h51jenjys0bYUV8eD5QtQ2JvDwom+XhIYNVUSqvG90Wwvzh8XeGAGi5g9aDGWDXcq8sSHyaoBxGrn6dnH1f0RxWCkuOsjidc23Urf+JrhCc0WDKGyGaNQS7A=" diff --git a/README.md b/README.md index c0f1079..af34303 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ## percona-server -[![Build Status](https://travis-ci.org/Oefenweb/ansible-percona-server.svg?branch=master)](https://travis-ci.org/Oefenweb/ansible-percona-server) +[![CI](https://github.com/Oefenweb/ansible-percona-server/workflows/CI/badge.svg)](https://github.com/Oefenweb/ansible-percona-server/actions?query=workflow%3ACI) [![Ansible Galaxy](http://img.shields.io/badge/ansible--galaxy-percona--server-blue.svg)](https://galaxy.ansible.com/Oefenweb/percona-server) Set up a [percona-server](https://www.percona.com/software/mysql-database/percona-server) server in Debian-like systems. diff --git a/defaults/main.yml b/defaults/main.yml index d6633c6..cfffadd 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -19,7 +19,7 @@ percona_server_user_root_cnf_preset: percona_server_user_root_cnf: "{{ percona_server_user_root_cnf_preset }}" percona_server_install: - - xtrabackup + - "percona-xtrabackup{{ '-80' if percona_server_version is version('8', '>=') else '-24' if percona_server_version is version('5.7', '>=') else '' }}" percona_server_ssl_map: {} diff --git a/tasks/configure.yml b/tasks/configure.yml index c21712d..8bd40c3 100644 --- a/tasks/configure.yml +++ b/tasks/configure.yml @@ -13,22 +13,22 @@ - percona-server-configure-copy-certificate-files - block: - - name: configure | service | stop - service: - name: mysql - state: stopped - tags: - - percona-server-configure-first-run-service-stop + - name: configure | service | stop + service: + name: mysql + state: stopped + tags: + - percona-server-configure-first-run-service-stop - - name: configure | remove (excessive) configuration files - file: - path: "{{ item }}" - state: absent - with_items: - - /etc/mysql/percona-server.cnf - - /etc/mysql/percona-server.conf.d - tags: - - percona-server-configure-first-run-cleanup + - name: configure | remove (excessive) configuration files + file: + path: "{{ item }}" + state: absent + with_items: + - /etc/mysql/percona-server.cnf + - /etc/mysql/percona-server.conf.d + tags: + - percona-server-configure-first-run-cleanup when: _mysqld_installed.rc != 0 tags: - percona-server-configure-first-run @@ -45,12 +45,12 @@ - percona-server-configure-global-my-cnf - block: - - name: configure | service | start - service: - name: mysql - state: started - tags: - - percona-server-configure-first-run-service-start + - name: configure | service | start + service: + name: mysql + state: started + tags: + - percona-server-configure-first-run-service-start when: _mysqld_installed.rc != 0 tags: - percona-server-configure-first-run diff --git a/tasks/ib-logfile.yml b/tasks/ib-logfile.yml index b01eeb7..7834874 100644 --- a/tasks/ib-logfile.yml +++ b/tasks/ib-logfile.yml @@ -17,35 +17,35 @@ # Instead of doing this in main.yml we do it here because of a bug in 2.2.0.0 - block: - - name: ib logfile | set InnoDB shutdown mode - mysql_variables: - variable: innodb_fast_shutdown - value: "1" - tags: - - percona-server-ib-logfile-innodb-fast-shutdown - - percona-server-ib-logfile-innodb-fast-shutdown-set + - name: ib logfile | set InnoDB shutdown mode + mysql_variables: + variable: innodb_fast_shutdown + value: "1" + tags: + - percona-server-ib-logfile-innodb-fast-shutdown + - percona-server-ib-logfile-innodb-fast-shutdown-set - - name: ib logfile | stop service - service: - name: mysql - state: stopped - tags: - - percona-server-ib-logfile-stop-service + - name: ib logfile | stop service + service: + name: mysql + state: stopped + tags: + - percona-server-ib-logfile-stop-service - - name: ib logfile | remove ib_logfile(s) - file: - path: "{{ item }}" - state: absent - with_items: - - "{{ percona_server_datadir.rstrip('/') }}/ib_logfile0" - - "{{ percona_server_datadir.rstrip('/') }}/ib_logfile1" - tags: - - percona-server-ib-logfile-remove + - name: ib logfile | remove ib_logfile(s) + file: + path: "{{ item }}" + state: absent + with_items: + - "{{ percona_server_datadir.rstrip('/') }}/ib_logfile0" + - "{{ percona_server_datadir.rstrip('/') }}/ib_logfile1" + tags: + - percona-server-ib-logfile-remove - - name: ib logfile | start service - service: - name: mysql - state: started - tags: - - percona-server-ib-logfile-start-service + - name: ib logfile | start service + service: + name: mysql + state: started + tags: + - percona-server-ib-logfile-start-service when: _mysqld_installed.rc != 0 diff --git a/tests/vagrant.yml b/tests/vagrant.yml index fa08688..d97c872 100644 --- a/tests/vagrant.yml +++ b/tests/vagrant.yml @@ -5,5 +5,3 @@ become: true roles: - ../../ - vars: - percona_server_version: 5.7