diff --git a/.github/workflows/molecule.yml b/.github/workflows/molecule.yml index a422025a..515a7b32 100644 --- a/.github/workflows/molecule.yml +++ b/.github/workflows/molecule.yml @@ -8,11 +8,11 @@ on: jobs: list-scenarios: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 outputs: matrix: ${{ steps.listscenarios.outputs.scenarios }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - id: listscenarios uses: ome/action-ansible-molecule-list-scenarios@main @@ -20,22 +20,21 @@ jobs: name: Test needs: - list-scenarios - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 strategy: # Keep running so we can see if other tests pass fail-fast: false matrix: scenario: ${{fromJson(needs.list-scenarios.outputs.matrix)}} steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: - python-version: '3.8' + python-version: '3.9' - name: Install Ansible & Molecule run: | pip install "ansible<8" "ansible-lint<6.13" flake8 pip install "molecule<5" "ansible-compat<4" pip install molecule-plugins[docker] pytest-testinfra - pip3.8 install jmespath - name: Run molecule run: molecule test -s "${{ matrix.scenario }}" diff --git a/README.md b/README.md index 798e3c28..33948d1d 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,11 @@ OME production services playbooks ================================= These playbooks encapsulate the running of various production servers run by the OME team. + +At the moment, only the `ome-demoserver.yml` playbook is available here. This is a playbook for OMERO.demo server on https://demo.openmicroscopy.org OMERO.server and OMERO.web. You can read more about this [OMERO.demo server on our website](https://www.openmicroscopy.org/explore/). + +We are in the process of adding more OME team's production playbooks here. + If you are looking for examples of running your own production OMERO.server see https://github.com/ome/omero-deployment-examples @@ -10,13 +15,20 @@ If you are looking for examples of running your own production OMERO.server see Details ------- -- Install `Ansible` and dependencies using the [ome-ansible-molecule package](https://pypi.org/project/ome-ansible-molecule/). +- Install `Ansible` >2.10 - Install required roles: `ansible-galaxy install -r requirements.yml` -- Run the [`site.yml` playbook](site.yml). +- Run the `ome-demoserver.yml` playbook: + +``` +cd playbooks +ansible-playbook --ask-become --become -i $PATH/TO/INVENTORY ome-demoserver.yml -l $YOUR-HOST-ADDRESS-OR-IP --diff +``` + -For details of individual playbooks see the comments in [`site.yml`](site.yml). Testing ------- -All server playbooks have a corresponding [molecule](https://molecule.readthedocs.io/) test scenario under [`molecule`](molecule). +We test the playbooks here on Rocky Linux 9 platform via [Ansible Molecule](https://molecule.readthedocs.io/), see test scenarios under [`molecule`](molecule). + +The main components of the playbooks (roles) are being independently tested on both Rocky Linux 9 and Ubuntu 22.04. See e.g. [ome.omero_server role](https://github.com/ome/ansible-role-omero-server/tree/master/molecule). diff --git a/Vagrantfile b/Vagrantfile deleted file mode 100644 index fd052344..00000000 --- a/Vagrantfile +++ /dev/null @@ -1,24 +0,0 @@ -Vagrant.configure("2") do |config| - config.vm.box = "centos/7" - config.vm.provider "virtualbox" do |vb| - vb.customize ["modifyvm", :id, "--memory", "2048"] - config.vm.network "forwarded_port", guest: 80, host: 8080 - config.vm.network "forwarded_port", guest: 4064, host: 4064 - config.vm.network "forwarded_port", guest: 4063, host: 4063 - end - - [ - "ome-dundeeomero", - "ome-demoserver", - "nightshade-web" - ].each do |server| - config.vm.define "#{server}" do |node| - node.vm.box = "centos/7" - node.vm.provision "ansible" do |ansible| - ansible.playbook = "tests/#{server}.yml" - config.vm.provision "ansible" do |ansible| - ansible.skip_tags = "lvm" - ansible.playbook = "#{server}.yml" - ansible.galaxy_role_file = "requirements.yml" - end -end diff --git a/ansible.cfg b/ansible.cfg index 50758f18..76048139 100644 --- a/ansible.cfg +++ b/ansible.cfg @@ -10,7 +10,7 @@ [defaults] # Galaxy roles -roles_path = ./vendor +roles_path = ./playbooks/roles # These tend to be annoying. retry_files_enabled = False diff --git a/bootstrap/playbook.yml b/bootstrap/playbook.yml deleted file mode 100644 index 1dc43c86..00000000 --- a/bootstrap/playbook.yml +++ /dev/null @@ -1,36 +0,0 @@ ---- -# Playbook which runs the necessary root-level steps -# so that a host can be managed by others -- name: Boot1 - hosts: omedev - roles: - - - role: ome.network - - - role: ome.lvm_partition - lvm_lvname: var_log - lvm_lvmount: /var/log - lvm_lvsize: 4g - lvm_lvfilesystem: xfs - lvm_vgname: VolGroup00 - - role: ome.lvm_partition - lvm_lvname: root - lvm_lvmount: / - lvm_lvsize: 100%FREE - lvm_lvfilesystem: xfs - lvm_vgname: VolGroup00 - lvm_shrink: false - - - role: ome.sudoers - sudoers_individual_commands: - - user: "%omedev" - become: ALL - command: "NOPASSWD: ALL" - - - role: ome.upgrade_distpackages - upgrade_distpackages_reboot_kernel: true - -- name: Network - hosts: vlan-10ge-servers, vlan-ome-idr-docker - roles: - - role: ome.network diff --git a/k8s/README.md b/k8s/README.md deleted file mode 100644 index 554016f2..00000000 --- a/k8s/README.md +++ /dev/null @@ -1,17 +0,0 @@ -# OME kubernetes suport playbooks - -## `bootstrap` - -Provisioning tasks intended to be run once when provisioning a new system. -This includes networking configuration. - - -## `prerequisites` - -These tasks should be run before a Kubernetes cluster is promoted to production use. -It should be safe to re-run these playbooks at any time. - - -## `postgres` - -An standalone PostgreSQL server for use by Kubernetes applications. diff --git a/k8s/bootstrap/playbook.yml b/k8s/bootstrap/playbook.yml deleted file mode 100644 index c31b457f..00000000 --- a/k8s/bootstrap/playbook.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -- name: Bootkub - hosts: vlan-10ge-servers - roles: - - role: ome.network diff --git a/k8s/prerequisites/playbook.yml b/k8s/prerequisites/playbook.yml deleted file mode 100644 index 9eec5c17..00000000 --- a/k8s/prerequisites/playbook.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- -- name: Kuberneteslochy - hosts: kubernetes-lochy-k8s - roles: - # No mounts are configured, this just installs required packages - - role: ome.nfs_mount diff --git a/molecule/bootstrap/molecule.yml b/molecule/bootstrap/molecule.yml deleted file mode 100644 index 359f74fe..00000000 --- a/molecule/bootstrap/molecule.yml +++ /dev/null @@ -1,28 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -driver: - name: docker -lint: | - yamllint . - ansible-lint - flake8 -platforms: - - name: omedev - image: centos:7 -provisioner: - name: ansible - playbooks: - converge: ../../bootstrap/playbook.yml - lint: - name: ansible-lint -scenario: - name: bootstrap - test_sequence: - - lint - - dependency - - syntax -verifier: - name: testinfra diff --git a/molecule/docker-prod/Dockerfile.j2 b/molecule/docker-prod/Dockerfile.j2 deleted file mode 100644 index 7e2d467d..00000000 --- a/molecule/docker-prod/Dockerfile.j2 +++ /dev/null @@ -1,22 +0,0 @@ -# Molecule managed - -{% if item.registry is defined %} -FROM {{ item.registry.url }}/{{ item.image }} -{% else %} -FROM {{ item.image }} -{% endif %} - -{% if item.env is defined %} -{% for var, value in item.env.items() %} -{% if value %} -ENV {{ var }} {{ value }} -{% endif %} -{% endfor %} -{% endif %} - -RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get install -y python sudo python-jmespath bash ca-certificates iproute2 && apt-get clean; \ - elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python sudo python-devel python*-dnf bash iproute && dnf clean all; \ - elif [ $(command -v yum) ]; then yum makecache fast && yum install -y python sudo python36-jmespath python38-jmespath yum-plugin-ovl bash iproute ca-certificates && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \ - elif [ $(command -v zypper) ]; then zypper refresh && zypper install -y python sudo bash python-xml iproute2 && zypper clean -a; \ - elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates; \ - elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates iproute2 && xbps-remove -O; fi diff --git a/molecule/docker-prod/converge.yml b/molecule/docker-prod/converge.yml deleted file mode 100644 index 775d3456..00000000 --- a/molecule/docker-prod/converge.yml +++ /dev/null @@ -1,19 +0,0 @@ ---- -- name: Converge - hosts: ome-dockr-prod1.openmicroscopy.org - tasks: - - name: Workaround to get host IP inside docker - shell: hostname -I | cut -d' ' -f1 - register: hostname_ip - check_mode: false - changed_when: false - tags: - # Ignore [306] Shells that use pipes should set the pipefail option - - skip_ansible_lint - - - name: Set address of postgres for redmine - set_fact: - redmine_tracker_db_host: "{{ hostname_ip.stdout }}" - -- name: Import-playbook - import_playbook: ../../omedev/docker-prod-apps.yml diff --git a/molecule/docker-prod/molecule.yml b/molecule/docker-prod/molecule.yml deleted file mode 100644 index f43e3aa3..00000000 --- a/molecule/docker-prod/molecule.yml +++ /dev/null @@ -1,56 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -driver: - name: docker -lint: | - yamllint . - ansible-lint - flake8 -platforms: - - name: ome-dockr-prod1.openmicroscopy.org - image: centos/systemd:latest - command: /sbin/init - privileged: true - groups: - - docker-hosts - - omedev-docker - published_ports: - - "0.0.0.0:9090:9090/tcp" -provisioner: - name: ansible - playbooks: - prepare: prepare.yml - converge: converge.yml - inventory: - host_vars: - ome-dockr-prod1.openmicroscopy.org: - ome_monitored_node_exporter_hosts: - - node.example.org - ome_monitored_postgres_hosts: - - pg.example.org - ome_monitored_omero_server_hosts: - - omeroserver.example.org - ome_monitored_omero_web_hosts: - - omeroweb.example.org - prometheus_docker_data_volume: /srv/prometheus - nfs_minio_data_volume: /srv/minio - redmine_tracker_docker_data_volume: /srv/redmine-files - - group_vars: - # all: - # molecule_test: true - docker-hosts: - # This should allow docker-in-docker to work - docker_storage_driver: vfs - # Latest version 17.12.1.ce-1.el7.centos has a bug that prevents - # testing on travis: https://github.com/docker/for-linux/issues/219 - docker_version: 17.09.1.ce-1.el7.centos - lint: - name: ansible-lint -scenario: - name: docker-prod -verifier: - name: testinfra diff --git a/molecule/docker-prod/prepare.yml b/molecule/docker-prod/prepare.yml deleted file mode 100644 index 7bb8ba41..00000000 --- a/molecule/docker-prod/prepare.yml +++ /dev/null @@ -1,22 +0,0 @@ ---- -- name: Prepare - hosts: ome-dockr-prod1.openmicroscopy.org - roles: - - role: ome.postgresql - postgresql_version: "13" - postgresql_server_auth: - - database: redmine - user: redmine - address: 0.0.0.0/0 - postgresql_databases: - - name: redmine - owner: redmine - postgresql_users: - - user: redmine - password: redmine - databases: - - redmine - postgresql_server_listen: "'*'" - -- name: Import playbook - import_playbook: ../../omedev/playbook.yml diff --git a/molecule/docker-prod/tests/test_default.py b/molecule/docker-prod/tests/test_default.py deleted file mode 100644 index ced9ed28..00000000 --- a/molecule/docker-prod/tests/test_default.py +++ /dev/null @@ -1,39 +0,0 @@ -import json -import os -import testinfra.utils.ansible_runner - -testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( - os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all') - - -def test_prometheus_targets(host): - out = host.check_output( - 'curl -k -f --user admin:monitoring ' - 'https://localhost/prometheus/api/v1/targets') - d = json.loads(out) - assert d['status'] == 'success' - assert d['data']['droppedTargets'] == [] - unique_instances = set( - t['labels']['instance'] for t in d['data']['activeTargets']) - assert len({ - 'node.example.org:443', - 'pg.example.org:443', - 'omeroserver.example.org:443', - 'omeroweb.example.org:443', - 'idr.openmicroscopy.org:443', - 'idr1.openmicroscopy.org:443', - 'idr2.openmicroscopy.org:443', - 'localhost:9090', - }.difference(unique_instances)) == 0 - - -def test_minio_connect(host): - out = host.check_output('curl -s http://localhost:9000 -I') - assert 'Server: MinIO/' in out - - -def test_redmine_connect(host): - out = host.check_output( - 'curl -k -f -L -H "Host: idr-redmine-docker.openmicroscopy.org" ' - 'https://localhost/') - assert '