diff --git a/.kitchen.yml b/.kitchen.yml deleted file mode 100644 index ed370bc..0000000 --- a/.kitchen.yml +++ /dev/null @@ -1,28 +0,0 @@ ---- -driver: - name: vagrant - -provisioner: - hosts: test-kitchen - name: ansible_playbook - require_chef_for_busser: false - require_ruby_for_busser: true - require_ansible_omnibus: true - ansible_verbosity: 3 - ansible_verbose: true -# Fix for: https://github.com/ansible/ansible/issues/23016 - ansible_version: 2.2.0 - extra_vars: - sphinx_test: true - -platforms: - - name: ubuntu-16.04 - - name: debian-7.11 - - name: debian-8.7 - -suites: - - name: default - -# Fix for: https://github.com/neillturner/kitchen-ansible/issues/66 -verifier: - ruby_bindir: '/usr/bin' diff --git a/.travis.yml b/.travis.yml index ffdb204..ca4a62d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,17 +3,17 @@ language: generic python: "2.7" sudo: required -dist: trusty +dist: bionic matrix: include: - - env: ANSIBLE_VERSION=1.9.6 - - env: ANSIBLE_VERSION=2.1.2.0 + - env: ANSIBLE_VERSION=2.8.6 + - env: ANSIBLE_VERSION=2.10.2 before_install: - sudo apt-get update -qq - sudo apt-get install -y git software-properties-common python-pip aptitude - - sudo aptitude install -y mysql-client-5.5 + - sudo apt-get install -y mysql-client - sudo pip install ansible==$ANSIBLE_VERSION - ansible --version diff --git a/defaults/main.yml b/defaults/main.yml index 53bbdce..e386bc9 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -11,7 +11,6 @@ sphinx_searchd: read_timeout: 5 max_children: 30 pid_file: "{{ sphinx_rundir }}/searchd.pid" - max_matches: 1000 seamless_rotate: 1 preopen_indexes: 1 unlink_old: 1 @@ -34,4 +33,3 @@ sphinx_indexes: name: "test_index" source: "test_source" path: "{{ sphinx_datadir }}/data/test_index" - charset_type: "utf-8" diff --git a/handlers/main.yml b/handlers/main.yml index 7215230..764406d 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -1,12 +1,15 @@ --- -- name: rotate all indexes - command: /usr/bin/indexer --rotate --all - register: rotate_result - failed_when: "rotate_result.rc > 0 and 'no indexes found' not in rotate_result.stdout" +- name: generate all indexes + command: /usr/bin/indexer --all - name: restart sphinx service: name="{{ sphinx_service_name }}" state=restarted - name: reload sphinx service: name="{{ sphinx_service_name }}" state=reloaded + +- name: rotate all indexes + command: /usr/bin/indexer --rotate --all + register: rotate_result + failed_when: "rotate_result.rc > 0 and 'no indexes found' not in rotate_result.stdout" diff --git a/meta/main.yml b/meta/main.yml index bba2ddf..c5fddd0 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -1,16 +1,18 @@ --- galaxy_info: author: "Semyon Deviatkin" + description: This role installs and configures the Sphinx search engine. license: BSD - min_ansible_version: 1.4 + min_ansible_version: 2.8.6 platforms: - name: Ubuntu versions: - - trusty + - xenial + - bionic - name: Debian versions: + - buster - wheezy - - jessie - name: EL versions: - 7 diff --git a/molecule/default/INSTALL.rst b/molecule/default/INSTALL.rst new file mode 100644 index 0000000..0c4bf5c --- /dev/null +++ b/molecule/default/INSTALL.rst @@ -0,0 +1,23 @@ +********************************* +Vagrant driver installation guide +********************************* + +Requirements +============ + +* Vagrant +* Virtualbox, Parallels, VMware Fusion, VMware Workstation or VMware Desktop + +Install +======= + +Please refer to the `Virtual environment`_ documentation for installation best +practices. If not using a virtual environment, please consider passing the +widely recommended `'--user' flag`_ when invoking ``pip``. + +.. _Virtual environment: https://virtualenv.pypa.io/en/latest/ +.. _'--user' flag: https://packaging.python.org/tutorials/installing-packages/#installing-to-the-user-site + +.. code-block:: bash + + $ pip install 'molecule_vagrant' diff --git a/molecule/default/converge.yml b/molecule/default/converge.yml new file mode 100644 index 0000000..2ca3177 --- /dev/null +++ b/molecule/default/converge.yml @@ -0,0 +1,8 @@ +--- +- name: Converge + hosts: all + become: yes + tasks: + - name: "Include sphinx" + include_role: + name: "sphinx" diff --git a/molecule/default/files b/molecule/default/files new file mode 120000 index 0000000..748ffc1 --- /dev/null +++ b/molecule/default/files @@ -0,0 +1 @@ +../../files/ \ No newline at end of file diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml new file mode 100644 index 0000000..800e362 --- /dev/null +++ b/molecule/default/molecule.yml @@ -0,0 +1,19 @@ +--- +dependency: + name: galaxy +driver: + name: vagrant +platforms: + - name: instance + box: bento/ubuntu-20.04 + memory: 512 + cpus: 1 +lint: | + set -e + yamllint *.yml + ansible-lint +# flake8 +provisioner: + name: ansible +verifier: + name: ansible diff --git a/molecule/default/verify.yml b/molecule/default/verify.yml new file mode 100644 index 0000000..bb7695f --- /dev/null +++ b/molecule/default/verify.yml @@ -0,0 +1,13 @@ +--- +# This is an example playbook to execute Ansible tests. + +- name: Verify + hosts: all + become: yes + gather_facts: false + tasks: + - name: Example assertion + command: /usr/local/bin/bats ./test/integration/default/bats/*.bats + - name: Example assertion + assert: + that: true diff --git a/tasks/config.yml b/tasks/config.yml index a9f7ca3..2c58032 100644 --- a/tasks/config.yml +++ b/tasks/config.yml @@ -9,7 +9,7 @@ - name: Tune net.ipv4.tcp_max_syn_backlog sysctl: name: net.ipv4.tcp_max_syn_backlog - value: 4096 + value: '4096' state: present reload: yes @@ -20,10 +20,10 @@ owner: root group: root mode: 0644 - when: sphinx_use_ext_config == False + when: not sphinx_use_ext_config notify: - rotate all indexes - restart sphinx - include: ext_config.yml - when: sphinx_use_ext_config == True + when: sphinx_use_ext_config diff --git a/tasks/ext_config.yml b/tasks/ext_config.yml index c8c0917..3ec4ae8 100644 --- a/tasks/ext_config.yml +++ b/tasks/ext_config.yml @@ -8,7 +8,7 @@ mode: 0755 state: directory with_items: - "conf.d" + - "conf.d" - name: Create the configuration file searchd.conf template: diff --git a/tasks/main.yml b/tasks/main.yml index 9bf15ce..3dc6c17 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -19,5 +19,3 @@ - name: Ensure sphinx is running and enabled service: name="{{ sphinx_service_name }}" state=started enabled=yes - tags: - - test diff --git a/tasks/package.yml b/tasks/package.yml index 551b18d..a4fd9c0 100644 --- a/tasks/package.yml +++ b/tasks/package.yml @@ -1,19 +1,11 @@ --- -- name: Add backports repository for Jessie release - apt_repository: repo="deb http://ftp.debian.org/debian jessie-backports main" state=present - when: ansible_os_family == "Debian" and ansible_distribution_release == "jessie" - - name: Install sphinx Debian package - apt: name={{ item }} state=present update_cache=yes - with_items: "{{ ubuntu_pkg }}" + apt: name="{{ ubuntu_pkg }}" state=present update_cache=yes when: ansible_os_family == "Debian" - name: Install sphinx RedHat dependencies - yum: name={{ item }} state=present - with_items: - - postgresql-libs - - unixODBC + yum: name="{{ rhel_dep_pkg }}" state=present when: ansible_os_family == "RedHat" - name: Install sphinx RedHat package diff --git a/tasks/test.yml b/tasks/test.yml index 03164a3..1492c0d 100644 --- a/tasks/test.yml +++ b/tasks/test.yml @@ -7,5 +7,7 @@ owner: root group: root mode: 0644 + notify: + - generate all indexes tags: - test diff --git a/test/integration/default.yml b/test/integration/default.yml index a910160..0cd27e3 100644 --- a/test/integration/default.yml +++ b/test/integration/default.yml @@ -1,4 +1,4 @@ - +--- - hosts: all roles: - sphinx diff --git a/vars/main.yml b/vars/main.yml index 5a89f83..d6162ae 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -3,5 +3,9 @@ ubuntu_pkg: - sphinxsearch +rhel_dep_pkg: + - postgresql-libs + - unixODBC + rhel_pkg: - http://sphinxsearch.com/files/sphinx-2.3.2-1.rhel7.x86_64.rpm