From 5ada96de19f663a0364566a2c764bff02241b169 Mon Sep 17 00:00:00 2001 From: Xavi Hernandez Date: Wed, 18 Oct 2023 14:39:08 +0000 Subject: [PATCH 01/29] Force a failure if some test fails The current approach detects failures but does continue with other tests. This is problematic because the ansible playbook execution completes successfully while there could have been some failed tests. This patch forces a failure when any test fails. This will fix the issue until a better test failure reporting is implemented. Signed-off-by: Xavi Hernandez --- playbooks/ansible/roles/tests/tasks/main.yml | 9 +++++++++ playbooks/ansible/roles/tests/tasks/run-test.yml | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/playbooks/ansible/roles/tests/tasks/main.yml b/playbooks/ansible/roles/tests/tasks/main.yml index 1969364c..2dc95ee3 100644 --- a/playbooks/ansible/roles/tests/tasks/main.yml +++ b/playbooks/ansible/roles/tests/tasks/main.yml @@ -1,4 +1,8 @@ --- +- name: Initialize test result + set_fact: + tests_failed: false + - name: Run tests include_tasks: run-test.yml vars: @@ -6,3 +10,8 @@ loop: "{{ config.tests }}" loop_control: loop_var: test_name + +- name: Check that tests succeeded + when: tests_failed + fail: + msg: "Some tests have failed" diff --git a/playbooks/ansible/roles/tests/tasks/run-test.yml b/playbooks/ansible/roles/tests/tasks/run-test.yml index 860ecc09..6a83ecaa 100644 --- a/playbooks/ansible/roles/tests/tasks/run-test.yml +++ b/playbooks/ansible/roles/tests/tasks/run-test.yml @@ -31,6 +31,10 @@ name: "{{ role }}" tasks_from: recover/main.yml + - name: Mark the test as failed + set_fact: + tests_failed: true + always: - name: Log test finalization time include_tasks: log.yml From 0e4f7645b84fd165c7c0f8276b161d4d9db331d2 Mon Sep 17 00:00:00 2001 From: Xavi Hernandez Date: Mon, 2 Oct 2023 11:19:16 +0000 Subject: [PATCH 02/29] Make paths relative to avoid hardcoded username Signed-off-by: Xavi Hernandez --- playbooks/Makefile | 8 ++++---- playbooks/ansible/roles/common.prep/tasks/main.yml | 8 ++++---- playbooks/ansible/roles/sit.cephfs/tasks/server/main.yml | 4 ++-- playbooks/roles/local.prep/tasks/main.yml | 4 ++-- playbooks/roles/setup.prep/tasks/main.yml | 8 ++++---- playbooks/roles/setup.test/tasks/main.yml | 7 ++++--- 6 files changed, 20 insertions(+), 19 deletions(-) diff --git a/playbooks/Makefile b/playbooks/Makefile index d7bcb85a..d31cc97a 100644 --- a/playbooks/Makefile +++ b/playbooks/Makefile @@ -25,21 +25,21 @@ setup.test.only: @ansible-playbook --inventory=$(INVENTORY) ${ANSIBLE_EXTRA_VARS} setup.test.yml setup.cluster.only: - @$(VSSH) admin "${SSH_EXTRA_VARS} make -C /home/vagrant/ansible setup.cluster" + @$(VSSH) admin "${SSH_EXTRA_VARS} make -C ansible setup.cluster" setup.cluster: setup.prep setup.test.only setup.cluster.only setup.clients: - @$(VSSH) admin "${SSH_EXTRA_VARS} make -C /home/vagrant/ansible setup.clients" + @$(VSSH) admin "${SSH_EXTRA_VARS} make -C ansible setup.clients" generate.report: - @$(VSSH) admin "${SSH_EXTRA_VARS} make -C /home/vagrant/ansible generate.report" + @$(VSSH) admin "${SSH_EXTRA_VARS} make -C ansible generate.report" nodes.statedump: @ansible-playbook --inventory $(INVENTORY) ${ANSIBLE_EXTRA_VARS} nodes.statedump.yml client.test: - @$(VSSH) admin "${SSH_EXTRA_VARS} make -C /home/vagrant/ansible client.test" + @$(VSSH) admin "${SSH_EXTRA_VARS} make -C ansible client.test" setup.site: setup.cluster setup.clients generate.report client.test diff --git a/playbooks/ansible/roles/common.prep/tasks/main.yml b/playbooks/ansible/roles/common.prep/tasks/main.yml index 5973ed53..c9a492d0 100644 --- a/playbooks/ansible/roles/common.prep/tasks/main.yml +++ b/playbooks/ansible/roles/common.prep/tasks/main.yml @@ -13,18 +13,18 @@ - name: create ansible directory (for ssh key) file: - path: /home/vagrant/ansible + path: ansible state: directory - name: copy ssh key copy: - src: /home/vagrant/ansible/vagrant_insecure_private_ssh_key - dest: /home/vagrant/ansible/vagrant_insecure_private_ssh_key + src: vagrant_insecure_private_ssh_key + dest: ansible/vagrant_insecure_private_ssh_key - name: copy ssh config copy: src: ssh-config-setup - dest: /home/vagrant/.ssh/config + dest: .ssh/config - name: Create /etc/hosts template: diff --git a/playbooks/ansible/roles/sit.cephfs/tasks/server/main.yml b/playbooks/ansible/roles/sit.cephfs/tasks/server/main.yml index 8ecc382b..affe545b 100644 --- a/playbooks/ansible/roles/sit.cephfs/tasks/server/main.yml +++ b/playbooks/ansible/roles/sit.cephfs/tasks/server/main.yml @@ -17,7 +17,7 @@ fetch: flat: true src: /root/.ssh/id_rsa.pub - dest: "/home/vagrant/ansible/ceph-node-0-ssh-key.pub" + dest: ceph-node-0-ssh-key.pub - name: Populating non-bootstrap nodes authorized keys authorized_key: @@ -25,7 +25,7 @@ state: present key: "{{ lookup('file', pubkey) }}" vars: - pubkey: "/home/vagrant/ansible/ceph-node-0-ssh-key.pub" + pubkey: ceph-node-0-ssh-key.pub # Pull ceph container image for all nodes - name: Pull containers diff --git a/playbooks/roles/local.prep/tasks/main.yml b/playbooks/roles/local.prep/tasks/main.yml index 36b62391..83b66b7a 100644 --- a/playbooks/roles/local.prep/tasks/main.yml +++ b/playbooks/roles/local.prep/tasks/main.yml @@ -20,7 +20,7 @@ replace: path: ./ansible/vagrant_ansible_inventory regexp: "ansible_ssh_private_key_file='.*/\\.vagrant\\.d/insecure_private_key'" - replace: "ansible_ssh_private_key_file='/home/vagrant/ansible/vagrant_insecure_private_ssh_key'" + replace: "ansible_ssh_private_key_file='vagrant_insecure_private_ssh_key'" - name: dump ssh config command: vagrant ssh-config @@ -48,7 +48,7 @@ replace: path: ./ansible/ssh-config-setup regexp: "IdentityFile .*" - replace: "IdentityFile /home/vagrant/ansible/vagrant_insecure_private_ssh_key" + replace: "IdentityFile ansible/vagrant_insecure_private_ssh_key" - name: Create state directory structure on host file: diff --git a/playbooks/roles/setup.prep/tasks/main.yml b/playbooks/roles/setup.prep/tasks/main.yml index 340d7668..6c864eea 100644 --- a/playbooks/roles/setup.prep/tasks/main.yml +++ b/playbooks/roles/setup.prep/tasks/main.yml @@ -14,18 +14,18 @@ - name: copy ansible playbooks to setup machine synchronize: src: ansible/ - dest: /home/vagrant/ansible + dest: ansible - name: ensure permissions on ssh key file file: - path: /home/vagrant/ansible/vagrant_insecure_private_ssh_key + path: ansible/vagrant_insecure_private_ssh_key mode: u=rw,g=,o= owner: vagrant group: vagrant - name: change ownership of ansible directory and files file: - path: /home/vagrant/ansible + path: ansible owner: vagrant group: vagrant recurse: yes @@ -33,7 +33,7 @@ - name: copy ssh config in place copy: src: ansible/ssh-config-setup - dest: /home/vagrant/.ssh/config + dest: .ssh/config mode: 0600 owner: vagrant group: vagrant diff --git a/playbooks/roles/setup.test/tasks/main.yml b/playbooks/roles/setup.test/tasks/main.yml index c7282212..4de3443b 100644 --- a/playbooks/roles/setup.test/tasks/main.yml +++ b/playbooks/roles/setup.test/tasks/main.yml @@ -1,5 +1,6 @@ --- - name: test playbook node connectivity on the setup machine - command: >- - ansible-playbook -i /home/vagrant/ansible/vagrant_ansible_inventory - /home/vagrant/ansible/test.local.yml + command: + chdir: ansible + cmd: >- + ansible-playbook -i vagrant_ansible_inventory test.local.yml From 6255e24beb3924cce529bcc7692139aeea1888de Mon Sep 17 00:00:00 2001 From: Xavi Hernandez Date: Wed, 4 Oct 2023 08:48:17 +0000 Subject: [PATCH 03/29] Add a role for generic provisioning Signed-off-by: Xavi Hernandez --- playbooks/roles/local.provision/tasks/main.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 playbooks/roles/local.provision/tasks/main.yml diff --git a/playbooks/roles/local.provision/tasks/main.yml b/playbooks/roles/local.provision/tasks/main.yml new file mode 100644 index 00000000..b2d757cb --- /dev/null +++ b/playbooks/roles/local.provision/tasks/main.yml @@ -0,0 +1,10 @@ +--- +- name: Provision all machines + include_role: + name: "provisioner.{{ provisioner_name }}" + tasks_from: "{{ provision_action }}/main.yml" + vars: + data: "{{ config.provisioners[provisioner_name] }}" + loop: "{{ config.provisioners.keys() }}" + loop_control: + loop_var: provisioner_name From c07d6555d61c516accdd76d9aebd434c71ab7934 Mon Sep 17 00:00:00 2001 From: Xavi Hernandez Date: Wed, 4 Oct 2023 10:26:09 +0000 Subject: [PATCH 04/29] Create provisioners configuration for vagrant Signed-off-by: Xavi Hernandez --- .../local.defaults/templates/config.yml.j2 | 17 +++++++++++++++++ playbooks/roles/local.defaults/vars/main.yml | 13 +++++++++++++ 2 files changed, 30 insertions(+) diff --git a/playbooks/roles/local.defaults/templates/config.yml.j2 b/playbooks/roles/local.defaults/templates/config.yml.j2 index 57feed36..88bd4db2 100644 --- a/playbooks/roles/local.defaults/templates/config.yml.j2 +++ b/playbooks/roles/local.defaults/templates/config.yml.j2 @@ -25,6 +25,23 @@ config: tests: {{ tests }} + provisioners: + {%- for prov in environments[be].nodes | dict2items | map(attribute='value') | map(attribute='provisioner', default='vagrant') | unique +%} + {{ prov }}: + {%- for item in provisioners[prov] | default({}) +%} + {{ item }}: {{ provisioners[prov][item] }} + {%- endfor +%} + hosts: + {%- for name in environments[be].nodes +%} + {%- set data = environments[be].nodes[name] +%} + {%- if data.provisioner | default(environments[be].provisioner | default('vagrant')) == prov +%} + {%- for idx in range(data.instances | default(1)) +%} + - {{ name }}{{ idx }} + {%- endfor +%} + {%- endif +%} + {%- endfor +%} + {%- endfor +%} + nodes: {%- for name in environments[be].nodes +%} {%- set data = environments[be].nodes[name] +%} diff --git a/playbooks/roles/local.defaults/vars/main.yml b/playbooks/roles/local.defaults/vars/main.yml index 3acc69c6..a9397a5d 100644 --- a/playbooks/roles/local.defaults/vars/main.yml +++ b/playbooks/roles/local.defaults/vars/main.yml @@ -37,6 +37,19 @@ misc: tests: - sit-test-cases +provisioners: + vagrant: + images: + centos8: generic/centos8s + centos9: generic/centos9s + + networks: + private: 192.168.122.0/24 + public: 192.168.123.0/24 + +# # Storage pool to use for the virtual disks (optional) +# pool: data + # The `environments` object contains one entry for each defined backend, # which specifies the types of VMs to create, the amount of each one, and # the resources they need. From cf9f5fb7291647e6b6c6763010783109687fd731 Mon Sep 17 00:00:00 2001 From: Xavi Hernandez Date: Wed, 4 Oct 2023 12:56:26 +0000 Subject: [PATCH 05/29] Convert vagrant roles into a provisioner Signed-off-by: Xavi Hernandez --- playbooks/local.yml | 5 +++-- playbooks/roles/local.vagrant/tasks/main.yml | 15 --------------- .../tasks/create}/main.yml | 11 +++++++++++ .../provisioner.vagrant}/templates/Vagrantfile.j2 | 0 4 files changed, 14 insertions(+), 17 deletions(-) delete mode 100644 playbooks/roles/local.vagrant/tasks/main.yml rename playbooks/roles/{local.prep/tasks => provisioner.vagrant/tasks/create}/main.yml (89%) rename playbooks/{ => roles/provisioner.vagrant}/templates/Vagrantfile.j2 (100%) diff --git a/playbooks/local.yml b/playbooks/local.yml index 1f44718b..e7483239 100644 --- a/playbooks/local.yml +++ b/playbooks/local.yml @@ -2,7 +2,8 @@ - hosts: localhost connection: local become: no + vars: + provision_action: create roles: - local.defaults - - local.vagrant - - local.prep + - local.provision diff --git a/playbooks/roles/local.vagrant/tasks/main.yml b/playbooks/roles/local.vagrant/tasks/main.yml deleted file mode 100644 index 7e38e407..00000000 --- a/playbooks/roles/local.vagrant/tasks/main.yml +++ /dev/null @@ -1,15 +0,0 @@ ---- -- set_fact: - host_os: "{{ ansible_distribution }}" - host_os_version: "{{ ansible_distribution_major_version }}" - -- name: Setup Vagrant file - template: - src: Vagrantfile.j2 - dest: Vagrantfile - -- name: start vagrant vms - command: vagrant up --no-provision - -- name: provision vagrant vms - command: vagrant provision diff --git a/playbooks/roles/local.prep/tasks/main.yml b/playbooks/roles/provisioner.vagrant/tasks/create/main.yml similarity index 89% rename from playbooks/roles/local.prep/tasks/main.yml rename to playbooks/roles/provisioner.vagrant/tasks/create/main.yml index 83b66b7a..96b15486 100644 --- a/playbooks/roles/local.prep/tasks/main.yml +++ b/playbooks/roles/provisioner.vagrant/tasks/create/main.yml @@ -1,4 +1,15 @@ --- +- name: Setup Vagrant file + template: + src: Vagrantfile.j2 + dest: Vagrantfile + +- name: start vagrant vms + command: vagrant up --no-provision + +- name: provision vagrant vms + command: vagrant provision + - name: copy vagrant generated inventory file - local machine copy: src: .vagrant/provisioners/ansible/inventory/vagrant_ansible_inventory diff --git a/playbooks/templates/Vagrantfile.j2 b/playbooks/roles/provisioner.vagrant/templates/Vagrantfile.j2 similarity index 100% rename from playbooks/templates/Vagrantfile.j2 rename to playbooks/roles/provisioner.vagrant/templates/Vagrantfile.j2 From 25eed588015c78810b897a8c4c912f8f082d9256 Mon Sep 17 00:00:00 2001 From: Xavi Hernandez Date: Wed, 4 Oct 2023 13:56:37 +0000 Subject: [PATCH 06/29] Remove vagrant global settings Signed-off-by: Xavi Hernandez --- .../local.defaults/templates/config.yml.j2 | 14 +++++---- playbooks/roles/local.defaults/vars/main.yml | 15 ---------- .../templates/Vagrantfile.j2 | 29 +++++++++---------- 3 files changed, 22 insertions(+), 36 deletions(-) diff --git a/playbooks/roles/local.defaults/templates/config.yml.j2 b/playbooks/roles/local.defaults/templates/config.yml.j2 index 88bd4db2..d8a5f899 100644 --- a/playbooks/roles/local.defaults/templates/config.yml.j2 +++ b/playbooks/roles/local.defaults/templates/config.yml.j2 @@ -11,10 +11,10 @@ config: - "{{ os_info[os_name].distro }}.yml" - "{{ os_info[os_name].family }}.yml" vagrant: - {%- if vagrant.pool is defined +%} - pool: "{{ vagrant.pool }}" + {%- if provisioners['vagrant'].pool is defined +%} + pool: "{{ provisioners['vagrant'].pool }}" {%- endif +%} - image: "{{ vagrant.images[os_name] }}" + image: "{{ provisioners['vagrant'].images[os_name] }}" {%- endfor +%} be: @@ -26,7 +26,7 @@ config: tests: {{ tests }} provisioners: - {%- for prov in environments[be].nodes | dict2items | map(attribute='value') | map(attribute='provisioner', default='vagrant') | unique +%} + {%- for prov in environments[be].nodes | dict2items | map(attribute='value.provisioner', default='vagrant') | unique +%} {{ prov }}: {%- for item in provisioners[prov] | default({}) +%} {{ item }}: {{ provisioners[prov][item] }} @@ -45,20 +45,22 @@ config: nodes: {%- for name in environments[be].nodes +%} {%- set data = environments[be].nodes[name] +%} + {%- set prov = data.provisioner | default(environments[be].provisioner | default('vagrant')) +%} {%- for idx in range(data.instances | default(1)) +%} {{ name }}{{ idx }}: groups: {{ data.groups }} + provisioner: {{ prov }} os: {{ data.os | default(environments[be].os | default(os)) }} cpus: {{ data.cpus | default(environments[be].cpus) }} memory: {{ data.memory | default(environments[be].memory) }} disks: {{ data.disks | default([]) }} networks: {%- for net in data.networks | default({}) +%} - {{ net }}: {{ vagrant.networks[net] | ansible.utils.ipaddr(data.networks[net] + idx) | ansible.utils.ipaddr('address') }} + {{ net }}: {{ provisioners[prov].networks[net] | ansible.utils.ipaddr(data.networks[net] + idx) | ansible.utils.ipaddr('address') }} {%- endfor +%} ctdb: {%- for net in data.ctdb | default({}) +%} - {{ net }}: {{ vagrant.networks[net] | ansible.utils.ipaddr(data.ctdb[net] + idx) | ansible.utils.ipaddr('address') }} + {{ net }}: {{ provisioners[prov].networks[net] | ansible.utils.ipaddr(data.ctdb[net] + idx) | ansible.utils.ipaddr('address') }} {%- endfor +%} {%- endfor +%} {%- endfor +%} diff --git a/playbooks/roles/local.defaults/vars/main.yml b/playbooks/roles/local.defaults/vars/main.yml index a9397a5d..d9b1d2ed 100644 --- a/playbooks/roles/local.defaults/vars/main.yml +++ b/playbooks/roles/local.defaults/vars/main.yml @@ -13,21 +13,6 @@ os_info: distro: centos version: 9 -# Vagrant/VM global settings -vagrant: - # Vagrant image to use per OS - images: - centos8: generic/centos8s - centos9: generic/centos9s - - # Available networks for the VMs - networks: - private: 192.168.122.0/24 - public: 192.168.123.0/24 - -# # Storage pool to use for the virtual disks (optional) -# pool: data - misc: host: statedir: "/tmp" diff --git a/playbooks/roles/provisioner.vagrant/templates/Vagrantfile.j2 b/playbooks/roles/provisioner.vagrant/templates/Vagrantfile.j2 index 4a7bd39f..52a1424f 100644 --- a/playbooks/roles/provisioner.vagrant/templates/Vagrantfile.j2 +++ b/playbooks/roles/provisioner.vagrant/templates/Vagrantfile.j2 @@ -4,9 +4,8 @@ Vagrant.configure("2") do |config| config.ssh.insert_key = false - config.vm.provider :libvirt do |v,override| - override.vm.synced_folder '.', '/vagrant', disabled: true - + config.vm.synced_folder '.', '/vagrant', disabled: true + config.vm.provider :libvirt do |v| # We can not use qemu_use_session universally. See section "Upgrade/compatibility impact" # from the following Fedora doc: # https://fedoraproject.org/wiki/Changes/Vagrant_2.2_with_QEMU_Session @@ -21,32 +20,32 @@ Vagrant.configure("2") do |config| # https://github.com/heketi/heketi/pull/1008 v.cpu_mode = 'host-passthrough' end -{% for node in config.nodes %} - {%- set data = config.nodes[node] %} +{% for host in data.hosts %} + {%- set node = config.nodes[host] %} {%- set vm_idx = loop.index0 +%} - config.vm.define "{{ node }}" do |node| + config.vm.define "{{ host }}" do |node| node.vm.box = "{{ config.os[data.os].vagrant.image }}" - node.vm.hostname = "{{ node }}" - {%- for net in data.networks +%} - node.vm.network :private_network, ip: "{{ data.networks[net] }}" + node.vm.hostname = "{{ host }}" + {%- for net in node.networks +%} + node.vm.network :private_network, ip: "{{ node.networks[net] }}" {%- endfor +%} node.vm.provider :virtualbox do |vb| - {%- for size in data.disks +%} + {%- for size in node.disks +%} vb.customize [ "createhd", "--filename", "disk-{{ vm_idx }}{{ loop.index0 }}.vdi", "--size", {{ size * 1024 }} ] vb.customize [ "storageattach", :id, "--storagectl", "SATA Controller", "--port", {{ loop.index0 + 3 }}, "--device", 0, "--type", "hdd", "--medium", "disk-{{ vm_idx }}{{ loop.index0 }}.vdi" ] {%- endfor +%} - vb.memory = {{ data.memory }} - vb.cpus = {{ data.cpus }} + vb.memory = {{ node.memory }} + vb.cpus = {{ node.cpus }} end node.vm.provider :libvirt do |lv| {%- if config.os[data.os].vagrant.pool is defined +%} lv.storage_pool_name = "{{ config.os[data.os].vagrant.pool }}" {%- endif +%} - {%- for size in data.disks +%} + {%- for size in node.disks +%} lv.storage :file, :device => "vd{{ "bcdefghijklmnopqrstuvwxyz"[loop.index0] }}", :path => "disk-{{ vm_idx }}{{ loop.index0 }}.disk", :size => '{{ size }}G' {%- endfor +%} - lv.memory = {{ data.memory }} - lv.cpus = {{ data.cpus }} + lv.memory = {{ node.memory }} + lv.cpus = {{ node.cpus }} end {%- if loop.last +%} From f9f95af3107317c85ad1502a55a05fe7d339a478 Mon Sep 17 00:00:00 2001 From: Xavi Hernandez Date: Wed, 4 Oct 2023 15:11:30 +0000 Subject: [PATCH 07/29] Make OS configurable per host Signed-off-by: Xavi Hernandez --- playbooks/roles/local.defaults/templates/config.yml.j2 | 5 ----- .../roles/provisioner.vagrant/templates/Vagrantfile.j2 | 6 +++--- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/playbooks/roles/local.defaults/templates/config.yml.j2 b/playbooks/roles/local.defaults/templates/config.yml.j2 index d8a5f899..231df37d 100644 --- a/playbooks/roles/local.defaults/templates/config.yml.j2 +++ b/playbooks/roles/local.defaults/templates/config.yml.j2 @@ -10,11 +10,6 @@ config: - "{{ os_info[os_name].distro }}{{ os_info[os_name].version}}.yml" - "{{ os_info[os_name].distro }}.yml" - "{{ os_info[os_name].family }}.yml" - vagrant: - {%- if provisioners['vagrant'].pool is defined +%} - pool: "{{ provisioners['vagrant'].pool }}" - {%- endif +%} - image: "{{ provisioners['vagrant'].images[os_name] }}" {%- endfor +%} be: diff --git a/playbooks/roles/provisioner.vagrant/templates/Vagrantfile.j2 b/playbooks/roles/provisioner.vagrant/templates/Vagrantfile.j2 index 52a1424f..f5b3b12f 100644 --- a/playbooks/roles/provisioner.vagrant/templates/Vagrantfile.j2 +++ b/playbooks/roles/provisioner.vagrant/templates/Vagrantfile.j2 @@ -24,7 +24,7 @@ Vagrant.configure("2") do |config| {%- set node = config.nodes[host] %} {%- set vm_idx = loop.index0 +%} config.vm.define "{{ host }}" do |node| - node.vm.box = "{{ config.os[data.os].vagrant.image }}" + node.vm.box = "{{ provisioners[node.provisioner].images[node.os] }}" node.vm.hostname = "{{ host }}" {%- for net in node.networks +%} node.vm.network :private_network, ip: "{{ node.networks[net] }}" @@ -38,8 +38,8 @@ Vagrant.configure("2") do |config| vb.cpus = {{ node.cpus }} end node.vm.provider :libvirt do |lv| - {%- if config.os[data.os].vagrant.pool is defined +%} - lv.storage_pool_name = "{{ config.os[data.os].vagrant.pool }}" + {%- if data.pool is defined +%} + lv.storage_pool_name = "{{ data.pool }}" {%- endif +%} {%- for size in node.disks +%} lv.storage :file, :device => "vd{{ "bcdefghijklmnopqrstuvwxyz"[loop.index0] }}", :path => "disk-{{ vm_idx }}{{ loop.index0 }}.disk", :size => '{{ size }}G' From 4315c9c9a7901800fca5f101a93950d98815b42b Mon Sep 17 00:00:00 2001 From: Xavi Hernandez Date: Wed, 4 Oct 2023 15:32:06 +0000 Subject: [PATCH 08/29] Add provisioner documentation Signed-off-by: Xavi Hernandez --- playbooks/roles/local.defaults/vars/main.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/playbooks/roles/local.defaults/vars/main.yml b/playbooks/roles/local.defaults/vars/main.yml index d9b1d2ed..037bc238 100644 --- a/playbooks/roles/local.defaults/vars/main.yml +++ b/playbooks/roles/local.defaults/vars/main.yml @@ -41,6 +41,10 @@ provisioners: # # Each environment has the following properties: # +# provisioner: (optional, default: 'vagrant') +# Default provisioner used to provision the hosts of the environment. +# This value can be overriden by specific VM type definitions. +# # os: (optional, default: `use_distro` if defined, 'centos9' otherwise) # Default OS installed on all hosts of the environment. This value can # be overriden by specific VM type definitions. @@ -66,6 +70,10 @@ provisioners: # # Each defined node type has the following properties: # +# provisioner: (optional, default: the value of `provisioner` in the +# environment) +# Provisioner used to provision this VM type. +# # os: (optional, default: the value of `os` in the environment) # OS installed on this VM type. # From e1091586a42eb2c80bf04dc50d5279b995cce5ff Mon Sep 17 00:00:00 2001 From: Xavi Hernandez Date: Wed, 4 Oct 2023 19:05:52 +0000 Subject: [PATCH 09/29] Create cleanup roles and playbooks Signed-off-by: Xavi Hernandez --- playbooks/Makefile | 13 +++---------- playbooks/cleanup.yml | 18 ++++++++++++++++++ playbooks/roles/local.clean/tasks/main.yml | 7 +++++++ .../provisioner.vagrant/tasks/destroy/main.yml | 15 +++++++++++++++ 4 files changed, 43 insertions(+), 10 deletions(-) create mode 100644 playbooks/cleanup.yml create mode 100644 playbooks/roles/local.clean/tasks/main.yml create mode 100644 playbooks/roles/provisioner.vagrant/tasks/destroy/main.yml diff --git a/playbooks/Makefile b/playbooks/Makefile index d31cc97a..70d43e8e 100644 --- a/playbooks/Makefile +++ b/playbooks/Makefile @@ -1,6 +1,5 @@ INVENTORY := ./vagrant_ansible_inventory VSSH := ssh -F ssh-config-host -VAGRANT := vagrant ifdef EXTRA_VARS ANSIBLE_EXTRA_VARS := -e '${EXTRA_VARS}' @@ -46,13 +45,7 @@ setup.site: setup.cluster setup.clients generate.report client.test client1.test: @$(VSSH) clients "sudo make -C /root/sit-test-cases test" -clean_vagrant: - -$(VAGRANT) destroy -f - -rm -rf .vagrant +clean: + @ansible-playbook --inventory localhost, ${ANSIBLE_EXTRA_VARS} cleanup.yml -clean_generated_files: - -rm -f Vagrantfile ansible/config.yml ansible/vagrant_ansible_inventory ansible/ssh-config-setup vagrant_ansible_inventory ssh-config-host - -clean: clean_vagrant clean_generated_files - -.PHONY: local hosts.update.only setup.prep.only setup.prep setup.test.only setup.cluster.only setup.cluster setup.clients client.test setup.site client1.test clean_vagrant clean_generated_files clean +.PHONY: local hosts.update.only setup.prep.only setup.prep setup.test.only setup.cluster.only setup.cluster setup.clients client.test setup.site client1.test clean diff --git a/playbooks/cleanup.yml b/playbooks/cleanup.yml new file mode 100644 index 00000000..e768ea1e --- /dev/null +++ b/playbooks/cleanup.yml @@ -0,0 +1,18 @@ +--- +- hosts: localhost + connection: local + become: no + gather_facts: false + vars_files: + - ansible/config.yml + vars: + provision_action: destroy + roles: + - local.provision + +- hosts: localhost + connection: local + become: no + gather_facts: false + roles: + - local.clean diff --git a/playbooks/roles/local.clean/tasks/main.yml b/playbooks/roles/local.clean/tasks/main.yml new file mode 100644 index 00000000..65cd988e --- /dev/null +++ b/playbooks/roles/local.clean/tasks/main.yml @@ -0,0 +1,7 @@ +--- +- name: Delete generated files + file: + path: "{{ item }}" + state: absent + with_items: + - ansible/config.yml diff --git a/playbooks/roles/provisioner.vagrant/tasks/destroy/main.yml b/playbooks/roles/provisioner.vagrant/tasks/destroy/main.yml new file mode 100644 index 00000000..3b58ad32 --- /dev/null +++ b/playbooks/roles/provisioner.vagrant/tasks/destroy/main.yml @@ -0,0 +1,15 @@ +--- +- name: Destroy vagrant machines + command: vagrant destroy -f + +- name: Remove vagrant settings + file: + path: "{{ item }}" + state: absent + with_items: + - .vagrant + - Vagrantfile + - ansible/vagrant_ansible_inventory + - ansible/ssh-config-setup + - vagrant_ansible_inventory + - ssh-config-host From f369f239d736d0f12b04d6e6e8c98d3a1326a44a Mon Sep 17 00:00:00 2001 From: Xavi Hernandez Date: Thu, 5 Oct 2023 12:00:18 +0000 Subject: [PATCH 10/29] Rename generated inventory file to a generic name Signed-off-by: Xavi Hernandez --- .gitignore | 4 ++-- playbooks/Makefile | 2 +- playbooks/ansible/Makefile | 2 +- playbooks/environment.sh | 2 +- .../roles/provisioner.vagrant/tasks/create/main.yml | 10 +++++----- .../roles/provisioner.vagrant/tasks/destroy/main.yml | 4 ++-- playbooks/roles/setup.test/tasks/main.yml | 2 +- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index d7f5bd7d..32b9cae3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,8 @@ *~ playbooks/.vagrant -playbooks/ansible/vagrant_ansible_inventory +playbooks/ansible/site_inventory playbooks/ansible/ssh-config-setup -playbooks/vagrant_ansible_inventory +playbooks/site_inventory playbooks/ssh-config-host playbooks/Vagrantfile playbooks/ansible/config.yml diff --git a/playbooks/Makefile b/playbooks/Makefile index 70d43e8e..e94fbb93 100644 --- a/playbooks/Makefile +++ b/playbooks/Makefile @@ -1,4 +1,4 @@ -INVENTORY := ./vagrant_ansible_inventory +INVENTORY := ./site_inventory VSSH := ssh -F ssh-config-host ifdef EXTRA_VARS diff --git a/playbooks/ansible/Makefile b/playbooks/ansible/Makefile index 09c78f58..db6925b0 100644 --- a/playbooks/ansible/Makefile +++ b/playbooks/ansible/Makefile @@ -1,4 +1,4 @@ -INVENTORY := ./vagrant_ansible_inventory +INVENTORY := ./site_inventory ifdef EXTRA_VARS ANSIBLE_EXTRA_VARS := -e '${EXTRA_VARS}' diff --git a/playbooks/environment.sh b/playbooks/environment.sh index a0b257c3..b19731be 100644 --- a/playbooks/environment.sh +++ b/playbooks/environment.sh @@ -1,3 +1,3 @@ # source me -export ANSIBLE_INVENTORY=.vagrant/provisioners/ansible/inventory/vagrant_ansible_inventory +export ANSIBLE_INVENTORY=site_inventory diff --git a/playbooks/roles/provisioner.vagrant/tasks/create/main.yml b/playbooks/roles/provisioner.vagrant/tasks/create/main.yml index 96b15486..03d3ca66 100644 --- a/playbooks/roles/provisioner.vagrant/tasks/create/main.yml +++ b/playbooks/roles/provisioner.vagrant/tasks/create/main.yml @@ -13,23 +13,23 @@ - name: copy vagrant generated inventory file - local machine copy: src: .vagrant/provisioners/ansible/inventory/vagrant_ansible_inventory - dest: ./vagrant_ansible_inventory + dest: ./site_inventory - name: adapt inventory - ssh options blockinfile: - path: ./vagrant_ansible_inventory + path: ./site_inventory block: | [all:vars] ansible_ssh_common_args='-o StrictHostKeyChecking=no' - name: copy vagrant generated inventory file - setup machine copy: - src: ./vagrant_ansible_inventory - dest: ./ansible/vagrant_ansible_inventory + src: ./site_inventory + dest: ./ansible/site_inventory - name: adapt inventory - correct ssh key replace: - path: ./ansible/vagrant_ansible_inventory + path: ./ansible/site_inventory regexp: "ansible_ssh_private_key_file='.*/\\.vagrant\\.d/insecure_private_key'" replace: "ansible_ssh_private_key_file='vagrant_insecure_private_ssh_key'" diff --git a/playbooks/roles/provisioner.vagrant/tasks/destroy/main.yml b/playbooks/roles/provisioner.vagrant/tasks/destroy/main.yml index 3b58ad32..ae8618b1 100644 --- a/playbooks/roles/provisioner.vagrant/tasks/destroy/main.yml +++ b/playbooks/roles/provisioner.vagrant/tasks/destroy/main.yml @@ -9,7 +9,7 @@ with_items: - .vagrant - Vagrantfile - - ansible/vagrant_ansible_inventory + - ansible/site_inventory - ansible/ssh-config-setup - - vagrant_ansible_inventory + - site_inventory - ssh-config-host diff --git a/playbooks/roles/setup.test/tasks/main.yml b/playbooks/roles/setup.test/tasks/main.yml index 4de3443b..97c79ac8 100644 --- a/playbooks/roles/setup.test/tasks/main.yml +++ b/playbooks/roles/setup.test/tasks/main.yml @@ -3,4 +3,4 @@ command: chdir: ansible cmd: >- - ansible-playbook -i vagrant_ansible_inventory test.local.yml + ansible-playbook -i site_inventory test.local.yml From a5a402114ca1ccf69bf4067b599cfc7d56573c10 Mon Sep 17 00:00:00 2001 From: Xavi Hernandez Date: Thu, 5 Oct 2023 13:39:08 +0000 Subject: [PATCH 11/29] Rename insecure ssh key to a generic name Signed-off-by: Xavi Hernandez --- ...rant_insecure_private_ssh_key => insecure_private_ssh_key} | 0 playbooks/ansible/roles/common.prep/tasks/main.yml | 4 ++-- playbooks/roles/provisioner.vagrant/tasks/create/main.yml | 4 ++-- playbooks/roles/setup.prep/tasks/main.yml | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) rename playbooks/ansible/{vagrant_insecure_private_ssh_key => insecure_private_ssh_key} (100%) diff --git a/playbooks/ansible/vagrant_insecure_private_ssh_key b/playbooks/ansible/insecure_private_ssh_key similarity index 100% rename from playbooks/ansible/vagrant_insecure_private_ssh_key rename to playbooks/ansible/insecure_private_ssh_key diff --git a/playbooks/ansible/roles/common.prep/tasks/main.yml b/playbooks/ansible/roles/common.prep/tasks/main.yml index c9a492d0..eee4de06 100644 --- a/playbooks/ansible/roles/common.prep/tasks/main.yml +++ b/playbooks/ansible/roles/common.prep/tasks/main.yml @@ -18,8 +18,8 @@ - name: copy ssh key copy: - src: vagrant_insecure_private_ssh_key - dest: ansible/vagrant_insecure_private_ssh_key + src: insecure_private_ssh_key + dest: ansible/insecure_private_ssh_key - name: copy ssh config copy: diff --git a/playbooks/roles/provisioner.vagrant/tasks/create/main.yml b/playbooks/roles/provisioner.vagrant/tasks/create/main.yml index 03d3ca66..577de3a7 100644 --- a/playbooks/roles/provisioner.vagrant/tasks/create/main.yml +++ b/playbooks/roles/provisioner.vagrant/tasks/create/main.yml @@ -31,7 +31,7 @@ replace: path: ./ansible/site_inventory regexp: "ansible_ssh_private_key_file='.*/\\.vagrant\\.d/insecure_private_key'" - replace: "ansible_ssh_private_key_file='vagrant_insecure_private_ssh_key'" + replace: "ansible_ssh_private_key_file='insecure_private_ssh_key'" - name: dump ssh config command: vagrant ssh-config @@ -59,7 +59,7 @@ replace: path: ./ansible/ssh-config-setup regexp: "IdentityFile .*" - replace: "IdentityFile ansible/vagrant_insecure_private_ssh_key" + replace: "IdentityFile ansible/insecure_private_ssh_key" - name: Create state directory structure on host file: diff --git a/playbooks/roles/setup.prep/tasks/main.yml b/playbooks/roles/setup.prep/tasks/main.yml index 6c864eea..bccf2ff7 100644 --- a/playbooks/roles/setup.prep/tasks/main.yml +++ b/playbooks/roles/setup.prep/tasks/main.yml @@ -18,7 +18,7 @@ - name: ensure permissions on ssh key file file: - path: ansible/vagrant_insecure_private_ssh_key + path: ansible/insecure_private_ssh_key mode: u=rw,g=,o= owner: vagrant group: vagrant From 079321766f54e60a7453cdbab8f24c3f01bb7568 Mon Sep 17 00:00:00 2001 From: Xavi Hernandez Date: Thu, 5 Oct 2023 13:41:42 +0000 Subject: [PATCH 12/29] Remove references to vagrant user Signed-off-by: Xavi Hernandez --- playbooks/roles/setup.prep/tasks/main.yml | 40 +++++++++-------------- 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/playbooks/roles/setup.prep/tasks/main.yml b/playbooks/roles/setup.prep/tasks/main.yml index bccf2ff7..4fad845c 100644 --- a/playbooks/roles/setup.prep/tasks/main.yml +++ b/playbooks/roles/setup.prep/tasks/main.yml @@ -11,29 +11,21 @@ name: 'sit.{{ config.be.name }}' tasks_from: setup/main.yml -- name: copy ansible playbooks to setup machine - synchronize: - src: ansible/ - dest: ansible +- name: Prepare configuration files + become: false + block: + - name: copy ansible playbooks to setup machine + synchronize: + src: ansible/ + dest: ansible -- name: ensure permissions on ssh key file - file: - path: ansible/insecure_private_ssh_key - mode: u=rw,g=,o= - owner: vagrant - group: vagrant + - name: ensure permissions on ssh key file + file: + path: ansible/insecure_private_ssh_key + mode: u=rw,g=,o= -- name: change ownership of ansible directory and files - file: - path: ansible - owner: vagrant - group: vagrant - recurse: yes - -- name: copy ssh config in place - copy: - src: ansible/ssh-config-setup - dest: .ssh/config - mode: 0600 - owner: vagrant - group: vagrant + - name: copy ssh config in place + copy: + src: ansible/ssh-config-setup + dest: .ssh/config + mode: 0600 From 6d64dda80984ce496568fbc5b0728ccec5925dbf Mon Sep 17 00:00:00 2001 From: Sachin Prabhu Date: Mon, 6 Nov 2023 11:32:32 +0000 Subject: [PATCH 13/29] devel: fix inventory symlink Fix symlink to inventory in the devel directory. This allows us to use the ansible scripts in the devel directory. Signed-off-by: Sachin Prabhu --- devel/inventory | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devel/inventory b/devel/inventory index 7213b6d2..7219aaeb 120000 --- a/devel/inventory +++ b/devel/inventory @@ -1 +1 @@ -../vagrant/vagrant_ansible_inventory \ No newline at end of file +../playbooks/site_inventory \ No newline at end of file From b8f5f2eda1ad2cdfcc3f7e9699b278f10a6e0b3f Mon Sep 17 00:00:00 2001 From: Anoop C S Date: Tue, 7 Nov 2023 14:05:23 +0530 Subject: [PATCH 14/29] samba.setup: Wait for healthy cluster before smbd restart Signed-off-by: Anoop C S --- playbooks/ansible/roles/samba.setup/tasks/main.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/playbooks/ansible/roles/samba.setup/tasks/main.yml b/playbooks/ansible/roles/samba.setup/tasks/main.yml index ff8abbb7..64215c54 100644 --- a/playbooks/ansible/roles/samba.setup/tasks/main.yml +++ b/playbooks/ansible/roles/samba.setup/tasks/main.yml @@ -49,6 +49,14 @@ vars: name: '{{ item.share_name }}-{{ config.be.name }}-{{ config.be.variant }}' +- name: Ensure cluster is in HEALTHY state + run_once: yes + command: ctdb nodestatus all + register: nodestatus + until: nodestatus.rc == 0 + retries: 10 + delay: 2 + - name: Restart samba service: name: smb From fedec8253fa72ae86de7ac5dd683d5e93bf19b89 Mon Sep 17 00:00:00 2001 From: Xavi Hernandez Date: Thu, 2 Nov 2023 11:57:57 +0000 Subject: [PATCH 15/29] Increase VM specs Upgraded number of CPUs and memory for all backends: Storage node Client node XFS 4 CPUs / 4 GiB 4 CPUs / 4 GiB GlusterFS 8 CPUs / 8 GiB 4 CPUs / 4 GiB CephFS 8 CPUs / 8 GiB 4 CPUs / 4 GiB Signed-off-by: Xavi Hernandez --- playbooks/roles/local.defaults/vars/main.yml | 22 ++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/playbooks/roles/local.defaults/vars/main.yml b/playbooks/roles/local.defaults/vars/main.yml index 037bc238..955d684d 100644 --- a/playbooks/roles/local.defaults/vars/main.yml +++ b/playbooks/roles/local.defaults/vars/main.yml @@ -107,17 +107,21 @@ provisioners: # environments: glusterfs: - cpus: 2 - memory: 1024 + cpus: 8 + memory: 8192 nodes: setup: + cpus: 2 + memory: 1024 networks: private: 200 groups: [admin] os: centos8 client: + cpus: 4 + memory: 4096 networks: public: 5 groups: [clients] @@ -134,11 +138,13 @@ environments: os: centos8 xfs: - cpus: 2 - memory: 1024 + cpus: 4 + memory: 4096 nodes: setup: + cpus: 2 + memory: 1024 networks: private: 200 groups: [admin] @@ -158,14 +164,16 @@ environments: groups: [clients] cephfs: - cpus: 2 - memory: 1024 + cpus: 8 + memory: 8192 data: branch: main nodes: setup: + cpus: 2 + memory: 1024 networks: private: 200 groups: [admin] @@ -181,6 +189,8 @@ environments: groups: [cluster] client: + cpus: 4 + memory: 4096 networks: public: 5 groups: [clients] From 039f660c8d702991a1629b1ef7b59e345dcb9e7c Mon Sep 17 00:00:00 2001 From: Anoop C S Date: Thu, 2 Nov 2023 16:01:14 +0530 Subject: [PATCH 16/29] local.defaults: Use raw `backend` env in naming statedir Instead of processed backend name use the raw `backend` environment variable value for better discovery of statedir. Signed-off-by: Anoop C S --- playbooks/roles/local.defaults/templates/config.yml.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/playbooks/roles/local.defaults/templates/config.yml.j2 b/playbooks/roles/local.defaults/templates/config.yml.j2 index 231df37d..d4aa86f6 100644 --- a/playbooks/roles/local.defaults/templates/config.yml.j2 +++ b/playbooks/roles/local.defaults/templates/config.yml.j2 @@ -70,5 +70,5 @@ config: {%- endfor +%} {%- endfor +%} - statedir: "{{ misc.host.statedir }}/sit.{{ be }}_statedump" + statedir: "{{ misc.host.statedir }}/sit.{{ backend }}_statedump" configdir: "{{ misc.host.configdir }}" From 57e9532b9968fb8afeb8b5ac9ef91df977226e64 Mon Sep 17 00:00:00 2001 From: Anoop C S Date: Thu, 2 Nov 2023 14:45:35 +0530 Subject: [PATCH 17/29] config.collect: Continue in the absence of test-info file In those situations where environment was not setup correctly we fail to run any tests. This would mean that test-info.yml file is not linked and subsequent task to copy it fails. Therefore make sure that we collect rest of the logs and configuration by ignoring the errors while copying the test-info file. Signed-off-by: Anoop C S --- playbooks/roles/config.collect/tasks/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/playbooks/roles/config.collect/tasks/main.yml b/playbooks/roles/config.collect/tasks/main.yml index f9a5239b..e6d72396 100644 --- a/playbooks/roles/config.collect/tasks/main.yml +++ b/playbooks/roles/config.collect/tasks/main.yml @@ -12,6 +12,7 @@ - name: Copy test configuration data shell: cp /root/test-info.yml {{ config.configdir }} when: inventory_hostname in groups['clients'] + ignore_errors: true - name: Copy configuration directory synchronize: From d51272a042fcc0ad1e32ed8b13592ecfd2fc8f52 Mon Sep 17 00:00:00 2001 From: Anoop C S Date: Thu, 9 Nov 2023 12:31:32 +0530 Subject: [PATCH 18/29] tests: Fix the location of site-tests.log Since we copy the required playbooks from host, site-tests.log was always created within setup machine. As a result statedump process failed to copy it from setup machine. Therefore allow it to be created under /var/log so that statedump process can collect it from the client machine. Signed-off-by: Anoop C S --- playbooks/ansible/roles/tests/tasks/log.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/playbooks/ansible/roles/tests/tasks/log.yml b/playbooks/ansible/roles/tests/tasks/log.yml index d59efced..d9b90a1c 100644 --- a/playbooks/ansible/roles/tests/tasks/log.yml +++ b/playbooks/ansible/roles/tests/tasks/log.yml @@ -1,6 +1,5 @@ --- - name: Add a log entry to site-tests.log - delegate_to: localhost block: - name: Get current time command: date "+%Y-%m-%d %H-%M-%S.%3N" @@ -8,7 +7,7 @@ - name: Write the log entry to site-tests.log lineinfile: - dest: "{{ config.statedir }}/site-tests.log" + dest: /var/log/site-tests.log line: "{{ now.stdout }} {{ line }}" insertafter: EOF create: true From 5cc3ccc4b097574b17f97fa78112b45aca04208c Mon Sep 17 00:00:00 2001 From: Anoop C S Date: Wed, 8 Nov 2023 15:39:23 +0530 Subject: [PATCH 19/29] setup-cluster: Configure CTDB after Samba installation Signed-off-by: Anoop C S --- .../ansible/roles/ctdb.setup/tasks/main.yml | 13 +++++++++++++ .../ansible/roles/samba.setup/tasks/main.yml | 18 ------------------ playbooks/ansible/setup-cluster.yml | 2 +- 3 files changed, 14 insertions(+), 19 deletions(-) diff --git a/playbooks/ansible/roles/ctdb.setup/tasks/main.yml b/playbooks/ansible/roles/ctdb.setup/tasks/main.yml index bcf1b0f0..3031725e 100644 --- a/playbooks/ansible/roles/ctdb.setup/tasks/main.yml +++ b/playbooks/ansible/roles/ctdb.setup/tasks/main.yml @@ -82,3 +82,16 @@ - name: Restart ctdb service: name=ctdb state=restarted enabled=yes + +- name: Ensure cluster is in HEALTHY state + run_once: yes + command: ctdb nodestatus all + register: nodestatus + until: nodestatus.rc == 0 + retries: 20 + delay: 3 + +- name: Create test users with smbpasswd + shell: (echo {{ item.password }}; echo {{ item.password }})|smbpasswd -a {{ item.username }} + with_items: "{{ samba_users }}" + run_once: yes diff --git a/playbooks/ansible/roles/samba.setup/tasks/main.yml b/playbooks/ansible/roles/samba.setup/tasks/main.yml index 64215c54..5a7fc6dd 100644 --- a/playbooks/ansible/roles/samba.setup/tasks/main.yml +++ b/playbooks/ansible/roles/samba.setup/tasks/main.yml @@ -49,27 +49,9 @@ vars: name: '{{ item.share_name }}-{{ config.be.name }}-{{ config.be.variant }}' -- name: Ensure cluster is in HEALTHY state - run_once: yes - command: ctdb nodestatus all - register: nodestatus - until: nodestatus.rc == 0 - retries: 10 - delay: 2 - -- name: Restart samba - service: - name: smb - state: restarted - - name: Create test users user: name: "{{ item.username }}" uid: "{{ item.uid }}" state: present with_items: "{{ samba_users }}" - -- name: Create test users with smbpasswd - shell: (echo {{ item.password }}; echo {{ item.password }})|smbpasswd -a {{ item.username }} - with_items: "{{ samba_users }}" - run_once: yes diff --git a/playbooks/ansible/setup-cluster.yml b/playbooks/ansible/setup-cluster.yml index 84ee4dc1..84cb64a1 100644 --- a/playbooks/ansible/setup-cluster.yml +++ b/playbooks/ansible/setup-cluster.yml @@ -9,5 +9,5 @@ - common.prep - node.prep - "sit.{{ config.be.name }}" - - ctdb.setup - samba.setup + - ctdb.setup From 2c8ebb7471e4160a6aee90230c99a7a60e95e3cb Mon Sep 17 00:00:00 2001 From: Xavi Hernandez Date: Wed, 15 Nov 2023 15:33:34 +0000 Subject: [PATCH 20/29] Make settings file more accessible Instead of hiding the main settings file inside a role, make it easily accessible as "settings.yml" inside "playbooks" directory. Signed-off-by: Xavi Hernandez --- playbooks/roles/local.defaults/tasks/main.yml | 4 ++++ .../{roles/local.defaults/vars/main.yml => settings.yml} | 0 2 files changed, 4 insertions(+) rename playbooks/{roles/local.defaults/vars/main.yml => settings.yml} (100%) diff --git a/playbooks/roles/local.defaults/tasks/main.yml b/playbooks/roles/local.defaults/tasks/main.yml index 6949d908..ca2cc7c0 100644 --- a/playbooks/roles/local.defaults/tasks/main.yml +++ b/playbooks/roles/local.defaults/tasks/main.yml @@ -1,4 +1,8 @@ --- +- name: Load settings + include_vars: + file: "settings.yml" + - name: Generate config.yml in ansible directory template: src: config.yml.j2 diff --git a/playbooks/roles/local.defaults/vars/main.yml b/playbooks/settings.yml similarity index 100% rename from playbooks/roles/local.defaults/vars/main.yml rename to playbooks/settings.yml From 552933f15bfb4ec1f495767c5368a0fdb7e3a165 Mon Sep 17 00:00:00 2001 From: Sachin Prabhu Date: Fri, 10 Nov 2023 22:33:57 +0000 Subject: [PATCH 21/29] devel: setup samba build environment on storage0 only We do not need two nodes with the samba devel environment. Signed-off-by: Sachin Prabhu --- devel/centos8_build_setup.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devel/centos8_build_setup.yml b/devel/centos8_build_setup.yml index 81b19c9d..e0b609d1 100644 --- a/devel/centos8_build_setup.yml +++ b/devel/centos8_build_setup.yml @@ -1,5 +1,5 @@ --- -- hosts: cluster +- hosts: storage0 become: yes tasks: From e8eef6f7febf4b4df56950c0e810dce53a262ca3 Mon Sep 17 00:00:00 2001 From: Sachin Prabhu Date: Fri, 10 Nov 2023 23:14:51 +0000 Subject: [PATCH 22/29] devel: add centos9 build environment setup playbook Signed-off-by: Sachin Prabhu --- devel/Makefile | 3 ++ devel/centos9_build_setup.yml | 98 +++++++++++++++++++++++++++++++++++ 2 files changed, 101 insertions(+) create mode 100644 devel/centos9_build_setup.yml diff --git a/devel/Makefile b/devel/Makefile index 37adcd31..7bd9f74e 100644 --- a/devel/Makefile +++ b/devel/Makefile @@ -5,3 +5,6 @@ fix_ssh: centos8_build_setup: @ansible-playbook -i ${INVENTORY} centos8_build_setup.yml + +centos9_build_setup: + @ansible-playbook -i ${INVENTORY} centos9_build_setup.yml diff --git a/devel/centos9_build_setup.yml b/devel/centos9_build_setup.yml new file mode 100644 index 00000000..b12a6286 --- /dev/null +++ b/devel/centos9_build_setup.yml @@ -0,0 +1,98 @@ +--- +- hosts: storage0 + become: yes + tasks: + + - name: Install storage SIG packages + dnf: + name: + - centos-release-gluster10 + + # Grabbed list of packages from + # https://github.com/samba-in-kubernetes/samba-build/blob/main/packaging/samba-4.19.spec.j2 + - name: Install required rpms + dnf: + name: + - git + - gdb + - make + - gcc + - glibc-gconv-extra + - avahi-devel + - bison + - cups-devel + - dbus-devel + - docbook-style-xsl + - e2fsprogs-devel + - flex + - gawk + - gnupg2 + - gnutls-devel + - gpgme-devel + - jansson-devel + - krb5-devel + - libacl-devel + - libaio-devel + - libarchive-devel + - libattr-devel + - libcap-devel + - libicu-devel + - libcmocka-devel + - libtirpc-devel + - libuuid-devel + - libxslt + - lmdb + - mingw32-gcc + - mingw64-gcc + - ncurses-devel + - openldap-devel + - pam-devel + - perl-interpreter + - perl-generators + - perl(Archive::Tar) + - perl(Test::More) + - popt-devel + - python3-cryptography + - python3-devel + - python3-dns + - python3-requests + - python3-setuptools + - quota-devel + - readline-devel + - rpcgen + - rpcsvc-proto-devel + - sed + - systemd-rpm-macros + - libtasn1-devel + - libtasn1-tools + - xfsprogs-devel + - xz + - zlib-devel + - pkgconfig(libsystemd) + - mold + - libgfapi-devel + - libglusterfs-devel + - libcephfs-devel + - liburing-devel + - pcp-libs-devel + - librados-devel + - python3-iso8601 + - python3-pyasn1 + - bind + - krb5-server + - perl(ExtUtils::MakeMaker) + - perl(FindBin) + - perl(Parse::Yapp) + - lmdb-devel + - bind + - krb5-server + - python3-dateutil + - python3-iso8601 + - python3-pyasn1 + - ldb-tools + - python3-gpg + - python3-markdown + - python3-cryptography + - python3-setproctitle + - tdb-tools + state: latest From cd58d38a9ae5ae415d1437c0f6c71b2a4e2c3229 Mon Sep 17 00:00:00 2001 From: Sachin Prabhu Date: Fri, 10 Nov 2023 22:35:17 +0000 Subject: [PATCH 23/29] devel: add new playbook to disable clustered samba It is easier to develop for samba when using a single samba node to connect to the backing clustered filesystem. This ansible script takes an existing samba cluster installed usign the sit-environment project and converts it to single node samba setup running on storage0. Signed-off-by: Sachin Prabhu --- devel/Makefile | 3 +++ devel/single_node_samba_cluster.yml | 27 +++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 devel/single_node_samba_cluster.yml diff --git a/devel/Makefile b/devel/Makefile index 7bd9f74e..053e803e 100644 --- a/devel/Makefile +++ b/devel/Makefile @@ -8,3 +8,6 @@ centos8_build_setup: centos9_build_setup: @ansible-playbook -i ${INVENTORY} centos9_build_setup.yml + +single_node_samba_cluster: + @ansible-playbook -i ${INVENTORY} single_node_samba_cluster.yml diff --git a/devel/single_node_samba_cluster.yml b/devel/single_node_samba_cluster.yml new file mode 100644 index 00000000..1e848e01 --- /dev/null +++ b/devel/single_node_samba_cluster.yml @@ -0,0 +1,27 @@ +--- +- hosts: cluster + become: yes + tasks: + + - name: Stop ctdb service + ansible.builtin.service: + name: ctdb + state: stopped + enabled: no + + - name: Disable clustering in smb.conf + ansible.builtin.lineinfile: + path: /etc/samba/smb.conf + search_string: "clustering" + line: clustering = no + + - name: Start smb service on storage0 + ansible.builtin.service: + name: smb + state: started + enabled: yes + when: ansible_hostname == "storage0" + + - name: Add test1 user to samba standalone tdb + shell: (echo x; echo x)|smbpasswd -a test1 + when: ansible_hostname == "storage0" From 3d5435e83a487e8b6b3ebebf553ed6ae6127c102 Mon Sep 17 00:00:00 2001 From: Anoop C S Date: Tue, 21 Nov 2023 22:45:50 +0530 Subject: [PATCH 24/29] client-test: Remove unused client.test role We have an exact same copy in test.sit-test-cases role. Signed-off-by: Anoop C S --- .../ansible/roles/client.test/tasks/main.yml | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 playbooks/ansible/roles/client.test/tasks/main.yml diff --git a/playbooks/ansible/roles/client.test/tasks/main.yml b/playbooks/ansible/roles/client.test/tasks/main.yml deleted file mode 100644 index 7517604a..00000000 --- a/playbooks/ansible/roles/client.test/tasks/main.yml +++ /dev/null @@ -1,18 +0,0 @@ ---- -- name: Run tests - block: - - command: - chdir: /root/sit-test-cases - cmd: make test - register: test_output - - debug: var=test_output.stdout_lines - when: test_sanity_only is undefined - -- name: Run sanity tests - block: - - command: - chdir: /root/sit-test-cases - cmd: make sanity_test - register: test_output - - debug: var=test_output.stdout_lines - when: test_sanity_only is defined From 5ef47ac566d808d334b0e49d106fb4bda87bb14a Mon Sep 17 00:00:00 2001 From: Xavi Hernandez Date: Wed, 15 Nov 2023 12:39:49 +0000 Subject: [PATCH 25/29] Dynamically adjust memory assigned to VMs Now the memory assigned to each VM depends on the actual free memory in the system and a weight defined for each VM type. There's an absolute minimum that will be assigned to each VM, but the remaining memory will be distributed proportionally to the weight of each VM. Signed-off-by: Xavi Hernandez --- playbooks/roles/local.defaults/tasks/main.yml | 1 + .../local.defaults/templates/config.yml.j2 | 18 +++++- playbooks/settings.yml | 62 +++++++++++++++---- 3 files changed, 69 insertions(+), 12 deletions(-) diff --git a/playbooks/roles/local.defaults/tasks/main.yml b/playbooks/roles/local.defaults/tasks/main.yml index ca2cc7c0..af221e5f 100644 --- a/playbooks/roles/local.defaults/tasks/main.yml +++ b/playbooks/roles/local.defaults/tasks/main.yml @@ -11,6 +11,7 @@ os: "{{ use_distro | default('centos9') }}" be: "{{ (backend | default('glusterfs') | split('.'))[0] }}" variant: "{{ (backend | default('glusterfs') | split('.'))[1] | default('default') }}" + max_memory: "{{ ansible_memfree_mb }}" - name: Load configuration include_vars: diff --git a/playbooks/roles/local.defaults/templates/config.yml.j2 b/playbooks/roles/local.defaults/templates/config.yml.j2 index d4aa86f6..d8d4dc22 100644 --- a/playbooks/roles/local.defaults/templates/config.yml.j2 +++ b/playbooks/roles/local.defaults/templates/config.yml.j2 @@ -37,6 +37,22 @@ config: {%- endfor +%} {%- endfor +%} +{%- set total_mem = max_memory * ((memory | default(resources.memory | default(50))) | int) / 100 +%} +{%- set extra_mem = 0 +%} +{%- set base_mem = [] +%} +{%- set weight_mem = [] +%} +{%- for name in environments[be].nodes +%} +{%- set data = environments[be].nodes[name] +%} +{%- set count = data.instances | default(1) +%} +{%- set _ = base_mem.append(count * (data.memory | default(environments[be].memory))) +%} +{%- set _ = weight_mem.append(count * (data.memory_weight | default(1))) +%} +{%- endfor +%} +{%- set base_mem = base_mem | sum +%} +{%- set weight_mem = weight_mem | sum +%} +{%- if weight_mem > 0 +%} +{%- set extra_mem = ([ total_mem - base_mem, 0] | max) / weight_mem / 1024 +%} +{%- endif +%} + nodes: {%- for name in environments[be].nodes +%} {%- set data = environments[be].nodes[name] +%} @@ -47,7 +63,7 @@ config: provisioner: {{ prov }} os: {{ data.os | default(environments[be].os | default(os)) }} cpus: {{ data.cpus | default(environments[be].cpus) }} - memory: {{ data.memory | default(environments[be].memory) }} + memory: {{ (data.memory | default(environments[be].memory)) + 1024 * ((extra_mem * (data.memory_weight | default(1))) | int) }} disks: {{ data.disks | default([]) }} networks: {%- for net in data.networks | default({}) +%} diff --git a/playbooks/settings.yml b/playbooks/settings.yml index 955d684d..2ef52e76 100644 --- a/playbooks/settings.yml +++ b/playbooks/settings.yml @@ -18,6 +18,36 @@ misc: statedir: "/tmp" configdir: "/tmp/config" +resources: + # Percentage of free memory that will be used for sit-environment by default. + # It can be overriden by setting the `memory` extra variable. + # + # All VMs are guaranteed to use the minimum memory defined, even if this + # makes them use more than the amount of memory defined here. + # + # The actual amount of memory assigned to each VM is computed by dynamically + # distributing the portion of the free memory assigned to sit-environment + # proportionally based on the memory weight of each VM. + # + # B: Sum of the minimum memory assigned to each VM. + # T: Sum of the weights assigned to each VM. + # G: Total available memory to sit-environment, which is equal to the total + # free memory multiplied by the defined percentage. + # Mi: Total memory assigned to i-th VM. + # mi: Minimum memory assigned to i-th VM. + # wi: Weight assigned to i-th VM. + # + # Mi = mi + int(max(G - B, 0) * wi / T) + # + # Examples with 50% memory utilization and 1 GiB minimum: + # + # Weight 58 GiB Free 38 GiB Free 18 GiB Free 8 GiB Free + # setup0: 0 1 GiB 1 GiB 1 GiB 1 GiB + # client0: 1 6 GiB 4 GiB 2 GiB 1 GiB + # storage0: 2 11 GiB 7 GiB 3 GiB 1 GiB + # storage1: 2 11 GiB 7 GiB 3 GiB 1 GiB + memory: 50 + # List of tests to run tests: - sit-test-cases @@ -54,8 +84,8 @@ provisioners: # overridden by specific VM type definitions. # # memory: (required) -# Default amount of memory (in MiB) assigned to each VM. This value -# can be overridden by specific VM type definitions. +# Default minimum amount of memory (in MiB) assigned to each VM. This +# value can be overridden by specific VM type definitions. # # data: (optional, default: {}) # This field contains any extra data specific to the environment that @@ -84,7 +114,13 @@ provisioners: # Number of CPUs for this specific VM type. # # memory: (optional, default: the value of `memory` in the environment) -# Amount of memory for this specific VM type. +# Minimum amount of memory for this specific VM type. +# +# memory_weight: (optional, default: 1) +# Relative weight of the memory assigned to this VM type. A higher weight +# will assign more memory to this VM type. A value of 0 will use just the +# minimum memory defined by the `memory` option. See the comment in the +# `resources` section to see how this value works. # # disks: (optional, default: []) # List of additional disks for this type of VM (besides the system @@ -108,12 +144,12 @@ provisioners: environments: glusterfs: cpus: 8 - memory: 8192 + memory: 1024 nodes: setup: cpus: 2 - memory: 1024 + memory_weight: 0 networks: private: 200 groups: [admin] @@ -121,13 +157,14 @@ environments: client: cpus: 4 - memory: 4096 + memory_weight: 1 networks: public: 5 groups: [clients] storage: instances: 2 + memory_weight: 2 disks: [10, 10, 10] networks: private: 100 @@ -139,17 +176,18 @@ environments: xfs: cpus: 4 - memory: 4096 + memory: 1024 nodes: setup: cpus: 2 - memory: 1024 + memory_weight: 0 networks: private: 200 groups: [admin] storage: + memory_weight: 1 disks: [10] networks: private: 100 @@ -159,13 +197,14 @@ environments: groups: [cluster] client: + memory_weight: 1 networks: public: 5 groups: [clients] cephfs: cpus: 8 - memory: 8192 + memory: 1024 data: branch: main @@ -173,13 +212,14 @@ environments: nodes: setup: cpus: 2 - memory: 1024 + memory_weight: 0 networks: private: 200 groups: [admin] storage: instances: 3 + memory_weight: 2 disks: [10, 10, 10] networks: private: 100 @@ -190,7 +230,7 @@ environments: client: cpus: 4 - memory: 4096 + memory_weight: 1 networks: public: 5 groups: [clients] From 5dcf1b9de7d2c511685b41ee48fb20cb1c3c3fcd Mon Sep 17 00:00:00 2001 From: Xavi Hernandez Date: Wed, 15 Nov 2023 12:56:34 +0000 Subject: [PATCH 26/29] Dynamically adjust the number of CPUs assigned to VMs Now the number of CPUs assigned to each VM depends on the actual number of cores in the system and a weight defined for each VM type. There's an absolute minimum that will be assigned to each VM, but the remaining CPUs will be distributed proportionally to the weight of each VM. Signed-off-by: Xavi Hernandez --- playbooks/roles/local.defaults/tasks/main.yml | 1 + .../local.defaults/templates/config.yml.j2 | 13 ++++++- playbooks/settings.yml | 39 ++++++++++++++----- 3 files changed, 42 insertions(+), 11 deletions(-) diff --git a/playbooks/roles/local.defaults/tasks/main.yml b/playbooks/roles/local.defaults/tasks/main.yml index af221e5f..0822ba38 100644 --- a/playbooks/roles/local.defaults/tasks/main.yml +++ b/playbooks/roles/local.defaults/tasks/main.yml @@ -12,6 +12,7 @@ be: "{{ (backend | default('glusterfs') | split('.'))[0] }}" variant: "{{ (backend | default('glusterfs') | split('.'))[1] | default('default') }}" max_memory: "{{ ansible_memfree_mb }}" + max_cpu: "{{ ansible_processor_nproc }}" - name: Load configuration include_vars: diff --git a/playbooks/roles/local.defaults/templates/config.yml.j2 b/playbooks/roles/local.defaults/templates/config.yml.j2 index d8d4dc22..6b488d0b 100644 --- a/playbooks/roles/local.defaults/templates/config.yml.j2 +++ b/playbooks/roles/local.defaults/templates/config.yml.j2 @@ -38,19 +38,30 @@ config: {%- endfor +%} {%- set total_mem = max_memory * ((memory | default(resources.memory | default(50))) | int) / 100 +%} +{%- set total_cpu = max_cpu * ((cpu | default(resources.cpu | default(100))) | int) / 100 +%} {%- set extra_mem = 0 +%} +{%- set extra_cpu = 0 +%} {%- set base_mem = [] +%} +{%- set base_cpu = [] +%} {%- set weight_mem = [] +%} +{%- set weight_cpu = [] +%} {%- for name in environments[be].nodes +%} {%- set data = environments[be].nodes[name] +%} {%- set count = data.instances | default(1) +%} {%- set _ = base_mem.append(count * (data.memory | default(environments[be].memory))) +%} +{%- set _ = base_cpu.append(count * (data.cpus | default(environments[be].cpus))) +%} {%- set _ = weight_mem.append(count * (data.memory_weight | default(1))) +%} +{%- set _ = weight_cpu.append(count * (data.cpu_weight | default(1))) +%} {%- endfor +%} {%- set base_mem = base_mem | sum +%} +{%- set base_cpu = base_cpu | sum +%} {%- set weight_mem = weight_mem | sum +%} +{%- set weight_cpu = weight_cpu | sum +%} {%- if weight_mem > 0 +%} {%- set extra_mem = ([ total_mem - base_mem, 0] | max) / weight_mem / 1024 +%} +{%- endif +%} +{%- if weight_cpu > 0 +%} +{%- set extra_cpu = ([ total_cpu - base_cpu, 0] | max) / weight_cpu +%} {%- endif +%} nodes: @@ -62,7 +73,7 @@ config: groups: {{ data.groups }} provisioner: {{ prov }} os: {{ data.os | default(environments[be].os | default(os)) }} - cpus: {{ data.cpus | default(environments[be].cpus) }} + cpus: {{ (data.cpus | default(environments[be].cpus)) + ((extra_cpu * (data.cpu_weight | default(1))) | int) }} memory: {{ (data.memory | default(environments[be].memory)) + 1024 * ((extra_mem * (data.memory_weight | default(1))) | int) }} disks: {{ data.disks | default([]) }} networks: diff --git a/playbooks/settings.yml b/playbooks/settings.yml index 2ef52e76..100514b9 100644 --- a/playbooks/settings.yml +++ b/playbooks/settings.yml @@ -48,6 +48,15 @@ resources: # storage1: 2 11 GiB 7 GiB 3 GiB 1 GiB memory: 50 + # Percentage of the cores that will be used for sit-environment by default. + # It can be overriden by setting the `cpu` extra variable. + # + # This is equivalent to the `memory` option but applied to CPU cores. + # + # It's allowed to use a value higher than 100% assuming that some VMs will + # actually not use all the cores at 100%. + cpu: 100 + # List of tests to run tests: - sit-test-cases @@ -80,7 +89,7 @@ provisioners: # be overriden by specific VM type definitions. # # cpus: (required) -# Default number of CPUs to assign to each VM. This value can be +# Default minimum number of CPUs to assign to each VM. This value can be # overridden by specific VM type definitions. # # memory: (required) @@ -111,7 +120,13 @@ provisioners: # Defines how many VMs of this type will be created. # # cpus: (optional, default: the value of `cpus` in the environment) -# Number of CPUs for this specific VM type. +# Minimum number of CPUs for this specific VM type. +# +# cpu_weight: (optional, default: 1) +# Relative weight of the number of CPUs assigned to this VM type. A higher +# weight will assign more CPUs to this VM type. A value of 0 will use just +# the minimum number of CPUs defined by the `cpus` option. See the comment +# in the `resources` section to see how this value works. # # memory: (optional, default: the value of `memory` in the environment) # Minimum amount of memory for this specific VM type. @@ -143,12 +158,12 @@ provisioners: # environments: glusterfs: - cpus: 8 + cpus: 2 memory: 1024 nodes: setup: - cpus: 2 + cpu_weight: 0 memory_weight: 0 networks: private: 200 @@ -156,7 +171,7 @@ environments: os: centos8 client: - cpus: 4 + cpu_weight: 1 memory_weight: 1 networks: public: 5 @@ -164,6 +179,7 @@ environments: storage: instances: 2 + cpu_weight: 2 memory_weight: 2 disks: [10, 10, 10] networks: @@ -175,18 +191,19 @@ environments: os: centos8 xfs: - cpus: 4 + cpus: 2 memory: 1024 nodes: setup: - cpus: 2 + cpu_weight: 0 memory_weight: 0 networks: private: 200 groups: [admin] storage: + cpu_weight: 1 memory_weight: 1 disks: [10] networks: @@ -197,13 +214,14 @@ environments: groups: [cluster] client: + cpu_weight: 1 memory_weight: 1 networks: public: 5 groups: [clients] cephfs: - cpus: 8 + cpus: 2 memory: 1024 data: @@ -211,7 +229,7 @@ environments: nodes: setup: - cpus: 2 + cpu_weight: 0 memory_weight: 0 networks: private: 200 @@ -219,6 +237,7 @@ environments: storage: instances: 3 + cpu_weight: 2 memory_weight: 2 disks: [10, 10, 10] networks: @@ -229,7 +248,7 @@ environments: groups: [cluster] client: - cpus: 4 + cpu_weight: 1 memory_weight: 1 networks: public: 5 From 50c5915437cd502a74ddbfb115304a32891ec7ff Mon Sep 17 00:00:00 2001 From: Anoop C S Date: Tue, 21 Nov 2023 16:53:05 +0530 Subject: [PATCH 27/29] sit.xfs: Copy Samba-CTDB configuration from cluster nodes Signed-off-by: Anoop C S --- playbooks/roles/sit.xfs/tasks/config/main.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/playbooks/roles/sit.xfs/tasks/config/main.yml b/playbooks/roles/sit.xfs/tasks/config/main.yml index ed97d539..74fef69d 100644 --- a/playbooks/roles/sit.xfs/tasks/config/main.yml +++ b/playbooks/roles/sit.xfs/tasks/config/main.yml @@ -1 +1,7 @@ --- +- name: Copy necessary configuration directories + shell: cp -r {{ item }} {{ config.configdir }} + with_items: + - /etc/samba + - /etc/ctdb + when: inventory_hostname in groups['cluster'] From 082eb9275cd35bb9808851595e9a9fb0e0ed526c Mon Sep 17 00:00:00 2001 From: Anoop C S Date: Tue, 21 Nov 2023 22:01:23 +0530 Subject: [PATCH 28/29] test.sit-test-cases: Redirect test output to a file Instead of cluttering the jenkins job console output with detailed test results we could redirect everything to a separate file and make it available as artifacts for each job. Simplest way to achieve this redirection is to make use of '&>'[1] to include both STDOUT and STDERR. Location of such an output file is chosen to be under /var/log so that it also gets collected as part of statedump process. [1] https://www.gnu.org/software/bash/manual/html_node/Redirections.html(3.6.4) Signed-off-by: Anoop C S --- .../ansible/roles/test.sit-test-cases/tasks/main.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/playbooks/ansible/roles/test.sit-test-cases/tasks/main.yml b/playbooks/ansible/roles/test.sit-test-cases/tasks/main.yml index 7517604a..9af46ea7 100644 --- a/playbooks/ansible/roles/test.sit-test-cases/tasks/main.yml +++ b/playbooks/ansible/roles/test.sit-test-cases/tasks/main.yml @@ -1,18 +1,18 @@ --- - name: Run tests block: - - command: + - shell: chdir: /root/sit-test-cases - cmd: make test + cmd: make test &> /var/log/test.out register: test_output - debug: var=test_output.stdout_lines when: test_sanity_only is undefined - name: Run sanity tests block: - - command: + - shell: chdir: /root/sit-test-cases - cmd: make sanity_test + cmd: make sanity_test &> /var/log/test.out register: test_output - debug: var=test_output.stdout_lines when: test_sanity_only is defined From e2c392ae1ef7bb73799e6f44f96929f295b3eb71 Mon Sep 17 00:00:00 2001 From: Anoop C S Date: Wed, 22 Nov 2023 20:46:03 +0530 Subject: [PATCH 29/29] client-test: Disable printing test output * smbtorture tests have been configured[1] to print the results irrespective of the outcome. * Test output is now redirected to a separate file[2], additional debug lines from ansible are no longer required. Previous change from 15b8f6179f204c4ee3cce755e7fcc4498e0fe9d3 to configure ANSIBLE_STDOUT_CALLBACK option can also be avoided as entire results are now available in a separate file. [1] https://github.com/samba-in-kubernetes/sit-test-cases/pull/44 [2] https://github.com/samba-in-kubernetes/sit-environment/pull/67 Signed-off-by: Anoop C S --- playbooks/ansible/Makefile | 2 +- .../roles/test.sit-test-cases/tasks/main.yml | 18 ++++++------------ 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/playbooks/ansible/Makefile b/playbooks/ansible/Makefile index db6925b0..42722088 100644 --- a/playbooks/ansible/Makefile +++ b/playbooks/ansible/Makefile @@ -17,7 +17,7 @@ generate.report: @ansible-playbook -i $(INVENTORY) ${ANSIBLE_EXTRA_VARS} ./generate-report.yml client.test: - @ANSIBLE_STDOUT_CALLBACK=debug ansible-playbook -i $(INVENTORY) ${ANSIBLE_EXTRA_VARS} ./client-test.yml + @ansible-playbook -i $(INVENTORY) ${ANSIBLE_EXTRA_VARS} ./client-test.yml setup.site: setup.cluster setup.clients client.test diff --git a/playbooks/ansible/roles/test.sit-test-cases/tasks/main.yml b/playbooks/ansible/roles/test.sit-test-cases/tasks/main.yml index 9af46ea7..1abd8997 100644 --- a/playbooks/ansible/roles/test.sit-test-cases/tasks/main.yml +++ b/playbooks/ansible/roles/test.sit-test-cases/tasks/main.yml @@ -1,18 +1,12 @@ --- - name: Run tests - block: - - shell: - chdir: /root/sit-test-cases - cmd: make test &> /var/log/test.out - register: test_output - - debug: var=test_output.stdout_lines + shell: + chdir: /root/sit-test-cases + cmd: make test &> /var/log/test.out when: test_sanity_only is undefined - name: Run sanity tests - block: - - shell: - chdir: /root/sit-test-cases - cmd: make sanity_test &> /var/log/test.out - register: test_output - - debug: var=test_output.stdout_lines + shell: + chdir: /root/sit-test-cases + cmd: make sanity_test &> /var/log/test.out when: test_sanity_only is defined