Browse Source

add development scripts

gitops
Nicolas Massé 3 years ago
parent
commit
67044ab70d
  1. 27
      hacking/cloud-init/install.sh
  2. 53
      hacking/cloud-init/user-data.yaml
  3. 22
      hacking/pipelinerun/pipelinerun.yaml

27
hacking/cloud-init/install.sh

@ -0,0 +1,27 @@
#!/bin/bash
set -Eeuo pipefail
virsh destroy database || true
virsh undefine database || true
rm -rf /var/lib/libvirt/images/database
mkdir -p /var/lib/libvirt/images/base-images /var/lib/libvirt/images/database
if [ ! -f /var/lib/libvirt/images/base-images/Fedora-Cloud-Base-36-1.5.x86_64.qcow2 ]; then
curl -Lo /var/lib/libvirt/images/base-images/Fedora-Cloud-Base-36-1.5.x86_64.qcow2 https://download.fedoraproject.org/pub/fedora/linux/releases/36/Cloud/x86_64/images/Fedora-Cloud-Base-36-1.5.x86_64.qcow2
fi
# dnf install -y cloud-utils genisoimage
cloud-localds /var/lib/libvirt/images/database/cloud-init.iso user-data.yaml
virt-install --name database --autostart --noautoconsole --cpu host-passthrough \
--vcpus 2 --ram 4096 --os-variant fedora36 \
--disk path=/var/lib/libvirt/images/database/database.qcow2,backing_store=/var/lib/libvirt/images/base-images/Fedora-Cloud-Base-36-1.5.x86_64.qcow2,size=20 \
--network network=default \
--console pty,target.type=virtio --serial pty --import \
--disk path=/var/lib/libvirt/images/database/cloud-init.iso,readonly=on \
--sysinfo system.serial=ds=nocloud
virsh console database

53
hacking/cloud-init/user-data.yaml

@ -0,0 +1,53 @@
#cloud-config
users:
- name: nicolas
gecos: Nicolas MASSE
groups: wheel
lock_passwd: false
passwd: $6$XUTB20jVVXIqh78k$L1A9Lft5JlbOtNbeDP.fOZ5giLl09LfJGGCon5uwtsIhPJoNkj4SIk08Rb6vSowOps2ik5tlUwT2ZOZ6jjr7.0
ssh_authorized_keys:
- ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPR1tt58X0+vbvsCR12gMAqr+g7vjt1Fx/qqz9EiboIs nicolas@localhost.localdomain
- ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFW62WJXI1ZCMfNA4w0dMpL0fsldhbEfULNGIUB0nQui nmasse@localhost.localdomain
write_files:
- path: /etc/sudoers
content: |
Defaults !visiblepw
Defaults always_set_home
Defaults match_group_by_gid
Defaults always_query_group_plugin
Defaults env_reset
Defaults env_keep = "COLORS DISPLAY HOSTNAME HISTSIZE KDEDIR LS_COLORS"
Defaults env_keep += "MAIL QTDIR USERNAME LANG LC_ADDRESS LC_CTYPE"
Defaults env_keep += "LC_COLLATE LC_IDENTIFICATION LC_MEASUREMENT LC_MESSAGES"
Defaults env_keep += "LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE"
Defaults env_keep += "LC_TIME LC_ALL LANGUAGE LINGUAS _XKB_CHARSET XAUTHORITY"
Defaults secure_path = /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/var/lib/snapd/snap/bin
root ALL=(ALL) ALL
%wheel ALL=(ALL) NOPASSWD: ALL
#includedir /etc/sudoers.d
permissions: '0440'
append: false
- path: /root/bootstrap.sh
content: |
#!/bin/bash
set -Eeuo pipefail
PGSETUP_INITDB_OPTIONS=--auth-host=scram-sha-256 postgresql-setup --initdb --unit postgresql
sed -i.bak -E "s/^#*\s*listen_addresses\s*=\s*'[^']*'/listen_addresses = '0.0.0.0'/" /var/lib/pgsql/data/postgresql.conf
cat >> /var/lib/pgsql/data/pg_hba.conf <<EOF
host all all 0.0.0.0/0 scram-sha-256
EOF
systemctl start postgresql.service
systemctl enable postgresql.service
cd /tmp
sudo -u postgres psql -c "CREATE USER appli WITH ENCRYPTED PASSWORD 'secret'"
sudo -u postgres psql -c "CREATE DATABASE appli OWNER 'appli';"
permissions: '0755'
packages:
- postgresql-server
runcmd:
- [ "/root/bootstrap.sh" ]

22
hacking/pipelinerun/pipelinerun.yaml

@ -0,0 +1,22 @@
apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
generateName: demo-appdev-
spec:
serviceAccountName: tekton-robot
pipelineRef:
name: demo-appdev
params:
- name: gitRepositoryURL
value: https://github.com/nmasse-itix/demo-appdev.git
- name: outputContainerImage
value: image-registry.openshift-image-registry.svc.cluster.local:5000/demo-appdev/function
workspaces:
- name: scratch
volumeClaimTemplate:
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
Loading…
Cancel
Save