From e6fa74ff97b12b26884624c9e484c5a107217a81 Mon Sep 17 00:00:00 2001 From: Faustin Lammler Date: Wed, 29 Jan 2025 11:11:48 +0100 Subject: [PATCH] Fix molecule roles searching And clean some remaining `pip install` stuff in favor of `uv pip`. --- Makefile | 5 +- molecule/cluster/molecule.yml | 1 + molecule/default/molecule.yml | 1 + molecule/vagrant/converge.yml | 9 --- molecule/vagrant/molecule.yml | 38 ---------- molecule/vagrant/vars/Debian.yml | 1 - molecule/vagrant/vars/RedHat.yml | 1 - molecule/vagrant/vars/testvars.yml | 47 ------------ molecule/vagrant/verify.yml | 116 ----------------------------- 9 files changed, 3 insertions(+), 216 deletions(-) delete mode 100644 molecule/vagrant/converge.yml delete mode 100644 molecule/vagrant/molecule.yml delete mode 120000 molecule/vagrant/vars/Debian.yml delete mode 120000 molecule/vagrant/vars/RedHat.yml delete mode 100644 molecule/vagrant/vars/testvars.yml delete mode 100644 molecule/vagrant/verify.yml diff --git a/Makefile b/Makefile index 5cace8f..e8b6703 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,7 @@ install: ## Install all necessary tools @echo -e "source $(VENV_DIR)/bin/activate" install-pip-packages: ## Install python3 requirements - $(info --> Install requirements via `pip3`) + $(info --> Install requirements via `uv pip`) @( \ source $(VENV_DIR)/bin/activate; \ uv pip install -r requirements.txt; \ @@ -28,9 +28,6 @@ install-galaxy: ## Install galaxy requirements $(info --> Install galaxy requirements) ansible-galaxy collection install -r requirements.yml --force -p $(VENDOR_DIR)/collections -upgrade-pip-packages: ## Upgrade python3 requirements - $(shell command -v pip3) install -U -r requirements.txt - install-pre-commit: ## Install pre-commit tool $(info --> Install pre-commit tool via `pip3`) uv pip install pre-commit diff --git a/molecule/cluster/molecule.yml b/molecule/cluster/molecule.yml index a01e399..4ec5970 100644 --- a/molecule/cluster/molecule.yml +++ b/molecule/cluster/molecule.yml @@ -60,6 +60,7 @@ provisioner: ANSIBLE_DISPLAY_SKIPPED_HOSTS: false ANSIBLE_FORCE_COLOR: true ANSIBLE_GATHERING: explicit + ANSIBLE_ROLES_PATH: ../../.. playbooks: converge: ${MOLECULE_PLAYBOOK:-converge.yml} verifier: diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index 07bbbd7..7d3d141 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -15,6 +15,7 @@ provisioner: ANSIBLE_DISPLAY_SKIPPED_HOSTS: false ANSIBLE_FORCE_COLOR: true ANSIBLE_GATHERING: explicit + ANSIBLE_ROLES_PATH: ../../.. playbooks: converge: ${MOLECULE_PLAYBOOK:-converge.yml} verifier: diff --git a/molecule/vagrant/converge.yml b/molecule/vagrant/converge.yml deleted file mode 100644 index 887b93c..0000000 --- a/molecule/vagrant/converge.yml +++ /dev/null @@ -1,9 +0,0 @@ ---- -- name: Converge - hosts: all - gather_facts: true - vars_files: vars/testvars.yml - become: true - - roles: - - role: ansible-role-mariadb diff --git a/molecule/vagrant/molecule.yml b/molecule/vagrant/molecule.yml deleted file mode 100644 index 813d62d..0000000 --- a/molecule/vagrant/molecule.yml +++ /dev/null @@ -1,38 +0,0 @@ ---- -dependency: - name: galaxy -driver: - name: vagrant - provider: - name: libvirt -platforms: - - name: node1 - box: ${TESTBOX:-debian/buster64} - interfaces: - - network_name: private_network - ip: 192.168.56.11 - memory: 1024 - cpus: 2 - provider_options: - # using session with network leads to troubles - qemu_use_session: false - config_options: - synced_folder: true - instance_raw_config_args: - - 'vm.synced_folder ".", "/vagrant", type: "rsync"' - - name: node2 - box: ${TESTBOX:-debian/bullseye64} - interfaces: - - network_name: private_network - ip: 192.168.56.12 - memory: 1024 - cpus: 2 - provider_options: - # using session with network leads to troubles - qemu_use_session: false - instance_raw_config_args: - - 'vm.synced_folder ".", "/vagrant", type: "rsync"' -provisioner: - name: ansible -scenario: - name: vagrant diff --git a/molecule/vagrant/vars/Debian.yml b/molecule/vagrant/vars/Debian.yml deleted file mode 120000 index c6ef0b7..0000000 --- a/molecule/vagrant/vars/Debian.yml +++ /dev/null @@ -1 +0,0 @@ -../../../vars/Debian.yml \ No newline at end of file diff --git a/molecule/vagrant/vars/RedHat.yml b/molecule/vagrant/vars/RedHat.yml deleted file mode 120000 index 98913c1..0000000 --- a/molecule/vagrant/vars/RedHat.yml +++ /dev/null @@ -1 +0,0 @@ -../../../vars/RedHat.yml \ No newline at end of file diff --git a/molecule/vagrant/vars/testvars.yml b/molecule/vagrant/vars/testvars.yml deleted file mode 100644 index 9da6440..0000000 --- a/molecule/vagrant/vars/testvars.yml +++ /dev/null @@ -1,47 +0,0 @@ ---- -mariadb_server_id: 1 -mariadb_bind_address: 0.0.0.0 -mariadb_replication_role: primary - -mariadb_innodb_raw: | - innodb_buffer_pool_size = 512M - innodb_log_file_size = 64M - innodb_file_per_table = 1 - -mariadb_databases: - - name: db1 - collation: latin1_swedish_ci - encoding: latin1 - state: present - - name: db2 - state: present - replicate: true - -mariadb_users: - - name: user1 - host: "%" - password: user1passwd - priv: "db2.*:SELECT" - state: present - - name: user2 - host: 100.64.10.3 - password: user2passwd - priv: "db2.*:ALL" - state: present - -mariadb_replication_user: - - name: ReplicationUser - host: 100.64.10.33 - password: ReplicationPassword - state: present - -# backup -mariadb_backup_db: true -mariadb_backup_db_cron_min: "50" -mariadb_backup_db_cron_hour: "00" -mariadb_backup_db_dir: "/mnt/backup" -mariadb_backup_db_rotation: "15" - -mariadb_backup_db_name: - - db1 - - db2 diff --git a/molecule/vagrant/verify.yml b/molecule/vagrant/verify.yml deleted file mode 100644 index 402937f..0000000 --- a/molecule/vagrant/verify.yml +++ /dev/null @@ -1,116 +0,0 @@ ---- -- name: Verify - hosts: all - gather_facts: true - - tasks: - - name: Load OS-specific vars - ansible.builtin.include_vars: "{{ lookup('first_found', params) }}" - vars: - params: - files: - - "{{ ansible_distribution }}.yml" - - "{{ ansible_os_family }}.yml" - paths: - - "vars" - - - name: Gather package facts - ansible.builtin.package_facts: - manager: auto - - - name: Verify Packages - ansible.builtin.assert: - that: "'mariadb-server' in ansible_facts.packages|lower" - - - name: Register {{ mariadb_config_file }} - ansible.builtin.stat: - path: "{{ mariadb_config_file }}" - register: conf - - - name: Check {{ mariadb_config_file }} - ansible.builtin.assert: - that: - - conf.stat.exists is true - - conf.stat.pw_name == 'root' - - conf.stat.gr_name == 'root' - - - name: Register {{ mariadb_data_dir }} - ansible.builtin.stat: - path: "{{ mariadb_data_dir }}" - register: datadir - - - name: Check {{ mariadb_data_dir }} - ansible.builtin.assert: - that: - - datadir.stat.isdir is true - - datadir.stat.pw_name == "{{ mariadb_user }}" - - datadir.stat.gr_name == "{{ mariadb_user }}" - - - name: Register {{ mariadb_log_dir }} - ansible.builtin.stat: - path: "{{ mariadb_log_dir }}" - register: logdir - - - name: Check {{ mariadb_log_dir }} - ansible.builtin.assert: - that: - - logdir.stat.isdir is true - - logdir.stat.pw_name == "{{ mariadb_user }}" - - logdir.stat.gr_name == "{{ mariadb_user }}" - - - name: Get mariadb service status - ansible.builtin.systemd: - name: "mariadb" - register: mariadb_service - - - name: Check that mariadb service is active - ansible.builtin.assert: - that: - - mariadb_service.status.ActiveState == 'active' - - - name: Check that 127.0.0.1:3306 is listening - ansible.builtin.wait_for: - port: 3306 - timeout: 2 - - - name: Get MariaDB version - ansible.builtin.shell: | - sudo mariadb -Bse 'STATUS' | grep "^Server version:" - register: version - when: lookup('env', 'MARIADB_VERSION') - - - name: Check MariaDB version - ansible.builtin.assert: - that: - - lookup('env', 'MARIADB_VERSION') in version.stdout - msg: "{{ version.stdout }}" - when: lookup('env', 'MARIADB_VERSION') - - - name: Check that Innodb engine is enabled (and default) - ansible.builtin.shell: | - sudo mariadb -Bse 'SHOW ENGINES' | grep -qE '^InnoDB.DEFAULT.*YES.YES.YES$' - - - name: Check that default db exist - ansible.builtin.shell: | - sudo mariadb -Bse 'SHOW DATABASES' | grep -q '^{{ item }}$' - loop: - - mysql - - information_schema - - performance_schema - - - name: Check that test db exist - ansible.builtin.shell: | - sudo mariadb -Bse 'SHOW DATABASES' | grep -q '^{{ item }}$' - loop: - - db1 - - db2 - - - name: Do some SQL queries - ansible.builtin.shell: | - sudo mariadb -Bse 'DROP DATABASE IF EXIST db' - sudo mariadb -Bse 'CREATE DATABASE db' - sudo mariadb -e 'CREATE TABLE db.t_innodb(a1 SERIAL, c1 CHAR(8)) ENGINE=InnoDB; INSERT INTO db.t_innodb VALUES (1,"foo"),(2,"bar")' - sudo mariadb -e 'CREATE FUNCTION db.f() RETURNS INT DETERMINISTIC RETURN 1' - sudo mariadb -e 'SHOW TABLES IN db' - sudo mariadb -e 'SELECT * FROM db.t_innodb; INSERT INTO db.t_innodb VALUES (3,"foo"),(4,"bar")' - sudo mariadb -e 'SELECT db.f()'