Skip to content

Commit

Permalink
Merge branch 'main' into monitor
Browse files Browse the repository at this point in the history
  • Loading branch information
obnoxxx authored Nov 23, 2023
2 parents 940e7e2 + e2c392a commit 18ea1b2
Show file tree
Hide file tree
Showing 35 changed files with 453 additions and 170 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 6 additions & 0 deletions devel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,9 @@ fix_ssh:

centos8_build_setup:
@ansible-playbook -i ${INVENTORY} centos8_build_setup.yml

centos9_build_setup:
@ansible-playbook -i ${INVENTORY} centos9_build_setup.yml

single_node_samba_cluster:
@ansible-playbook -i ${INVENTORY} single_node_samba_cluster.yml
2 changes: 1 addition & 1 deletion devel/centos8_build_setup.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
- hosts: cluster
- hosts: storage0
become: yes
tasks:

Expand Down
98 changes: 98 additions & 0 deletions devel/centos9_build_setup.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion devel/inventory
27 changes: 27 additions & 0 deletions devel/single_node_samba_cluster.yml
Original file line number Diff line number Diff line change
@@ -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"
23 changes: 8 additions & 15 deletions playbooks/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
INVENTORY := ./vagrant_ansible_inventory
INVENTORY := ./site_inventory
VSSH := ssh -F ssh-config-host
VAGRANT := vagrant

ifdef EXTRA_VARS
ANSIBLE_EXTRA_VARS := -e '${EXTRA_VARS}'
Expand All @@ -25,34 +24,28 @@ 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

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
4 changes: 2 additions & 2 deletions playbooks/ansible/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
INVENTORY := ./vagrant_ansible_inventory
INVENTORY := ./site_inventory

ifdef EXTRA_VARS
ANSIBLE_EXTRA_VARS := -e '${EXTRA_VARS}'
Expand All @@ -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

Expand Down
File renamed without changes.
18 changes: 0 additions & 18 deletions playbooks/ansible/roles/client.test/tasks/main.yml

This file was deleted.

8 changes: 4 additions & 4 deletions playbooks/ansible/roles/common.prep/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: insecure_private_ssh_key
dest: ansible/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:
Expand Down
13 changes: 13 additions & 0 deletions playbooks/ansible/roles/ctdb.setup/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 0 additions & 10 deletions playbooks/ansible/roles/samba.setup/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,9 @@
vars:
name: '{{ item.share_name }}-{{ config.be.name }}-{{ config.be.variant }}'

- 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
4 changes: 2 additions & 2 deletions playbooks/ansible/roles/sit.cephfs/tasks/server/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
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:
user: root
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
Expand Down
18 changes: 6 additions & 12 deletions playbooks/ansible/roles/test.sit-test-cases/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
---
- name: Run tests
block:
- command:
chdir: /root/sit-test-cases
cmd: make test
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:
- command:
chdir: /root/sit-test-cases
cmd: make sanity_test
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
3 changes: 1 addition & 2 deletions playbooks/ansible/roles/tests/tasks/log.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
---
- 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"
register: now

- 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
Expand Down
9 changes: 9 additions & 0 deletions playbooks/ansible/roles/tests/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
---
- name: Initialize test result
set_fact:
tests_failed: false

- name: Run tests
include_tasks: run-test.yml
vars:
role: "test.{{ test_name }}"
loop: "{{ config.tests }}"
loop_control:
loop_var: test_name

- name: Check that tests succeeded
when: tests_failed
fail:
msg: "Some tests have failed"
4 changes: 4 additions & 0 deletions playbooks/ansible/roles/tests/tasks/run-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,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
Expand Down
2 changes: 1 addition & 1 deletion playbooks/ansible/setup-cluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
- common.prep
- node.prep
- "sit.{{ config.be.name }}"
- ctdb.setup
- samba.setup
- ctdb.setup
Loading

0 comments on commit 18ea1b2

Please sign in to comment.