From 6a0097f76be59964273afb907ae0d82b2a6e5990 Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Fri, 9 Feb 2024 17:01:03 -0800 Subject: [PATCH] Remove Vagrant development environment This removes all traces (I hope) of the Vagrant development environment, as discussed in https://github.com/fedora-infra/bodhi/pull/5565#issuecomment-1902074109 . I preserved the VS Code docs in a very half-assed way as it seemed nicer than just deleting them, but I hope somebody who actually uses VS Code can test it out and improve those. Signed-off-by: Adam Williamson --- Vagrantfile | 92 ----- .../roles/podman/files/greenwave-settings.py | 16 +- .../roles/podman/files/waiverdb-settings.py | 12 +- .../roles/podman/tasks/prep.yml | 12 - devel/ansible/playbook.yml | 19 - devel/ansible/roles/bodhi/defaults/main.yml | 5 - devel/ansible/roles/bodhi/files/.bashrc | 77 ---- devel/ansible/roles/bodhi/files/.vimrc | 3 - .../roles/bodhi/files/bodhi.httpd.conf | 7 - devel/ansible/roles/bodhi/files/bodhi.service | 13 - devel/ansible/roles/bodhi/files/bodhi.toml | 62 --- .../ansible/roles/bodhi/files/celery.service | 13 - devel/ansible/roles/bodhi/files/motd | 23 -- devel/ansible/roles/bodhi/handlers/main.yml | 5 - .../roles/bodhi/tasks/configure_stg.yml | 42 -- devel/ansible/roles/bodhi/tasks/main.yml | 375 ------------------ .../templates/create-freeipa-users-grps.py | 58 --- .../roles/rabbitmq/files/local-rabbitmq.te | 17 - .../rabbitmq/files/print-messages.service | 11 - devel/ansible/roles/rabbitmq/tasks/main.yml | 80 ---- devel/development.ini.example | 2 +- devel/docker/compose-services.yml | 54 --- devel/docker/settings/greenwave-settings.py | 15 - devel/docker/settings/restore_waiverdb.sh | 5 - devel/docker/settings/waiverdb-settings.py | 11 - devel/register-with-ipsilon.py | 69 ---- docs/developer/bcd.rst | 32 +- docs/developer/bcd_vscode.rst | 76 ++++ docs/developer/index.rst | 26 +- docs/developer/vagrant.rst | 118 ------ docs/developer/vagrant_vscode.rst | 88 ---- docs/index.rst | 3 +- news/5600.dev | 1 + 33 files changed, 144 insertions(+), 1298 deletions(-) delete mode 100644 Vagrantfile mode change 120000 => 100644 devel/ansible-podman/roles/podman/files/greenwave-settings.py mode change 120000 => 100644 devel/ansible-podman/roles/podman/files/waiverdb-settings.py delete mode 100644 devel/ansible/playbook.yml delete mode 100644 devel/ansible/roles/bodhi/defaults/main.yml delete mode 100644 devel/ansible/roles/bodhi/files/.bashrc delete mode 100644 devel/ansible/roles/bodhi/files/.vimrc delete mode 100644 devel/ansible/roles/bodhi/files/bodhi.httpd.conf delete mode 100644 devel/ansible/roles/bodhi/files/bodhi.service delete mode 100644 devel/ansible/roles/bodhi/files/bodhi.toml delete mode 100644 devel/ansible/roles/bodhi/files/celery.service delete mode 100644 devel/ansible/roles/bodhi/files/motd delete mode 100644 devel/ansible/roles/bodhi/handlers/main.yml delete mode 100644 devel/ansible/roles/bodhi/tasks/configure_stg.yml delete mode 100644 devel/ansible/roles/bodhi/tasks/main.yml delete mode 100644 devel/ansible/roles/bodhi/templates/create-freeipa-users-grps.py delete mode 100644 devel/ansible/roles/rabbitmq/files/local-rabbitmq.te delete mode 100644 devel/ansible/roles/rabbitmq/files/print-messages.service delete mode 100644 devel/ansible/roles/rabbitmq/tasks/main.yml delete mode 100644 devel/docker/compose-services.yml delete mode 100644 devel/docker/settings/greenwave-settings.py delete mode 100755 devel/docker/settings/restore_waiverdb.sh delete mode 100644 devel/docker/settings/waiverdb-settings.py delete mode 100755 devel/register-with-ipsilon.py create mode 100644 docs/developer/bcd_vscode.rst delete mode 100644 docs/developer/vagrant.rst delete mode 100644 docs/developer/vagrant_vscode.rst create mode 100644 news/5600.dev diff --git a/Vagrantfile b/Vagrantfile deleted file mode 100644 index f73c44b33e..0000000000 --- a/Vagrantfile +++ /dev/null @@ -1,92 +0,0 @@ -# -*- mode: ruby -*- -# vi: set ft=ruby : - -# On your host: -# git clone https://github.com/fedora-infra/bodhi.git -# cd bodhi -# cp devel/Vagrantfile.example Vagrantfile -# vagrant up -# -# remember to set the value of fas_username - -require 'etc' - -VAGRANTFILE_API_VERSION = "2" - -fas_username = "" - -Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| - config.vm.box_url = "https://download.fedoraproject.org/pub/fedora/linux/releases/39/Cloud/x86_64/images/Fedora-Cloud-Base-Vagrant-39-1.5.x86_64.vagrant-libvirt.box" - config.vm.box = "f39-cloud-libvirt" - config.vm.box_download_checksum = "d8883192077049ad32f50c7b3414fc199cb7071aa60d736ba194f43f4be5836a" - config.vm.box_download_checksum_type = "sha256" - - # Forward traffic on the host to the development server on the guest. - # You can change the host port that is forwarded to 5000 on the guest - # if you have other services listening on your host's port 80. - config.vm.network "forwarded_port", guest: 6543, host: 6543 - - # Forward traffic on the host to the development waiverDB on the guest. - config.vm.network "forwarded_port", guest: 6544, host: 6544 - - # Forward traffic on the host to the development greenwave on the guest. - config.vm.network "forwarded_port", guest: 6545, host: 6545 - - # Forward traffic on the host to the RabbitMQ management UI on the guest. - # This allows developers to view message queues at http://localhost:15672/ - config.vm.network "forwarded_port", guest: 15672, host: 15672 - - # This is a plugin that updates the host's /etc/hosts - # file with the hostname of the guest VM. In Fedora it is packaged as - # ``vagrant-hostmanager`` - config.hostmanager.enabled = true - config.hostmanager.manage_host = true - - - # Vagrant can share the source directory using rsync, NFS, or SSHFS (with the vagrant-sshfs - # plugin). Consult the Vagrant documentation if you do not want to use SSHFS. - config.vm.synced_folder ".", "/vagrant", disabled: true - config.vm.synced_folder ".", "/home/vagrant/bodhi", type: "sshfs" - - # To cache update packages (which is helpful if frequently doing `vagrant destroy && vagrant up`) - # you can create a local directory and share it to the guest's DNF cache. Uncomment the lines below - # to create and use a dnf cache directory - # - # Dir.mkdir('.dnf-cache') unless File.exists?('.dnf-cache') - # config.vm.synced_folder ".dnf-cache", "/var/cache/dnf", type: "sshfs" - - # Comment this line if you would like to disable the automatic update during provisioning - config.vm.provision "shell", inline: "sudo dnf upgrade -y" - - # bootstrap and run with ansible - config.vm.provision "ansible" do |ansible| - ansible.playbook = "devel/ansible/playbook.yml" - ansible.extra_vars = { - fas_username: fas_username - } - end - - - # Create the bodhi dev box - config.vm.define "bodhi" do |bodhi| - bodhi.vm.host_name = "bodhi-dev.example.com" - - bodhi.vm.provider :libvirt do |domain| - # Season to taste - domain.cpus = Etc.nprocessors - domain.cpu_mode = "host-passthrough" - domain.graphics_type = "spice" - # The unit tests use a lot of RAM. - domain.memory = 4096 - domain.video_type = "qxl" - - # Enable libvirt's unsafe cache - # mode. It is called unsafe for a reason, as it causes the virtual host to ignore all - # fsync() calls from the guest. Only do this if you are comfortable with the possibility of - # your development guest becoming corrupted (in which case you should only need to do a - # vagrant destroy and vagrant up to get a new one). - #domain.volume_cache = "unsafe" - domain.disk_driver :cache => 'unsafe' - end - end -end diff --git a/devel/ansible-podman/roles/podman/files/greenwave-settings.py b/devel/ansible-podman/roles/podman/files/greenwave-settings.py deleted file mode 120000 index b1330bde24..0000000000 --- a/devel/ansible-podman/roles/podman/files/greenwave-settings.py +++ /dev/null @@ -1 +0,0 @@ -../../../../docker/settings/greenwave-settings.py \ No newline at end of file diff --git a/devel/ansible-podman/roles/podman/files/greenwave-settings.py b/devel/ansible-podman/roles/podman/files/greenwave-settings.py new file mode 100644 index 0000000000..21d1cfdd38 --- /dev/null +++ b/devel/ansible-podman/roles/podman/files/greenwave-settings.py @@ -0,0 +1,15 @@ +HOST = '0.0.0.0' +PORT = 6545 +DEBUG = False +POLICIES_DIR = '/etc/greenwave/policies/' +DIST_GIT_BASE_URL = 'https://src.fedoraproject.org' +DIST_GIT_URL_TEMPLATE = '{DIST_GIT_BASE_URL}/{pkg_namespace}/{pkg_name}/raw/{rev}/f/gating.yaml' +KOJI_BASE_URL = 'https://koji.fedoraproject.org/kojihub' + +SECRET_KEY = 'this-is-only-for-development' +WAIVERDB_API_URL = 'http://bodhi-dev-waiverdb:6544/api/v1.0' +RESULTSDB_API_URL = 'https://resultsdb.fedoraproject.org/api/v2.0' +CORS_URL = '*' +CACHE = { + "backend": "dogpile.cache.memory_pickle", +} diff --git a/devel/ansible-podman/roles/podman/files/waiverdb-settings.py b/devel/ansible-podman/roles/podman/files/waiverdb-settings.py deleted file mode 120000 index fe71516d20..0000000000 --- a/devel/ansible-podman/roles/podman/files/waiverdb-settings.py +++ /dev/null @@ -1 +0,0 @@ -../../../../docker/settings/waiverdb-settings.py \ No newline at end of file diff --git a/devel/ansible-podman/roles/podman/files/waiverdb-settings.py b/devel/ansible-podman/roles/podman/files/waiverdb-settings.py new file mode 100644 index 0000000000..1974b41ae7 --- /dev/null +++ b/devel/ansible-podman/roles/podman/files/waiverdb-settings.py @@ -0,0 +1,11 @@ +DATABASE_URI = 'postgresql+psycopg2://waiverdb@bodhi-dev-database:5432/waiverdb' +RESULTSDB_API_URL = 'https://resultsdb.fedoraproject.org/api/v2.0' +SECRET_KEY = 'this-is-only-for-development' +CORS_URL = '*' + +# MESSAGE_BUS_PUBLISH = True +MESSAGE_BUS_PUBLISH = False + +AUTH_METHOD = 'dummy' +SUPERUSERS = ['bodhi_user'] +PORT = 6544 diff --git a/devel/ansible-podman/roles/podman/tasks/prep.yml b/devel/ansible-podman/roles/podman/tasks/prep.yml index 565f1454d5..b213e173e6 100644 --- a/devel/ansible-podman/roles/podman/tasks/prep.yml +++ b/devel/ansible-podman/roles/podman/tasks/prep.yml @@ -43,18 +43,6 @@ - waiverdb-settings.py - greenwave-settings.py -- name: Adjust waiverdb hostname in greenwave settings for this environment - ansible.builtin.replace: - path: /tmp/bodhi-dev/greenwave-settings.py - regexp: 'waiverdb:6544' - replace: 'bodhi-dev-waiverdb:6544' - -- name: Adjust database hostname in waiverdb settings for this environment - ansible.builtin.replace: - path: /tmp/bodhi-dev/waiverdb-settings.py - regexp: 'wdb:5432' - replace: 'bodhi-dev-database:5432' - - name: Copy various required executable files into place ansible.builtin.copy: src: "{{ item }}" diff --git a/devel/ansible/playbook.yml b/devel/ansible/playbook.yml deleted file mode 100644 index 61d9c6daa7..0000000000 --- a/devel/ansible/playbook.yml +++ /dev/null @@ -1,19 +0,0 @@ ---- -- hosts: all - become: true - become_method: sudo - vars: - ansible_python_interpreter: /usr/bin/python3 - pre_tasks: - - name: Check if ipsilon.tinystage.test is reachable - shell: "ping -c 5 ipsilon.tinystage.test" - ignore_errors: yes - register: ping_response - - - name: Give reason for failure - fail: - msg: Provisioning bodhi requires the base tinystage setup to be running. - when: "ping_response.rc != 0" - roles: - - rabbitmq - - bodhi diff --git a/devel/ansible/roles/bodhi/defaults/main.yml b/devel/ansible/roles/bodhi/defaults/main.yml deleted file mode 100644 index a387ec3420..0000000000 --- a/devel/ansible/roles/bodhi/defaults/main.yml +++ /dev/null @@ -1,5 +0,0 @@ -rabbitmq_cluster_file_limit: 500000 -ipa_admin_user: admin -ipa_admin_password: password -krb_master_password: password -krb_realm: TINYSTAGE.TEST diff --git a/devel/ansible/roles/bodhi/files/.bashrc b/devel/ansible/roles/bodhi/files/.bashrc deleted file mode 100644 index dbd8716219..0000000000 --- a/devel/ansible/roles/bodhi/files/.bashrc +++ /dev/null @@ -1,77 +0,0 @@ -# .bashrc - -# Source global definitions -if [ -f /etc/bashrc ]; then - . /etc/bashrc -fi - -# Uncomment the following line if you don't like systemctl's auto-paging feature: -# export SYSTEMD_PAGER= -source /srv/venv/bin/activate - -shopt -s expand_aliases -alias bci="sudo -E /home/vagrant/bodhi/devel/ci/bodhi-ci" -alias bdocs="make -C /home/vagrant/bodhi/docs clean && make -C /home/vagrant/bodhi/docs html && make -C /home/vagrant/bodhi/docs man" -alias blog="sudo journalctl -u bodhi -u fm-consumer@config" -alias brestart="sudo systemctl restart bodhi && sudo systemctl restart fm-consumer@config && echo 'The Application is running on https://bodhi-dev.example.com'" -alias bstart="sudo systemctl start bodhi && sudo systemctl start fm-consumer@config && echo 'The Application is running on https://bodhi-dev.example.com'" -alias bstop="sudo systemctl stop bodhi && sudo systemctl stop fm-consumer@config" -alias blint="pre-commit run -a" -alias bmessages="sudo journalctl -u print-messages" - - -function bresetdb { - bstop; - sudo runuser -l postgres -c "psql -c \"DROP DATABASE bodhi2\""; - sudo runuser -l postgres -c 'createdb bodhi2'; - if [ ! -f "/tmp/bodhi2.dump.xz" ] ; then - curl -o /tmp/bodhi2.dump.xz https://infrastructure.fedoraproject.org/infra/db-dumps/bodhi2.dump.xz - fi - xzcat /tmp/bodhi2.dump.xz | sudo runuser -l postgres -c 'psql bodhi2'; - pushd /home/vagrant/bodhi/bodhi-server; - alembic upgrade head; - popd; - bstart; -} - - -function btest { - find /home/vagrant/bodhi -name "*.pyc" -delete; - blint || return $? - bdocs || return $? - for module in bodhi-messages bodhi-client bodhi-server; do - pushd $module - python -m pytest $@ tests || return $? - popd - done - diff-cover bodhi-*/coverage.xml --compare-branch=develop --fail-under=100 -} - - -function bstartdeps { - pushd /tmp; - curl -o waiverdb.dump.xz https://infrastructure.fedoraproject.org/infra/db-dumps/waiverdb.dump.xz - xz -d --keep --force waiverdb.dump.xz - popd; - pushd /home/vagrant/bodhi/devel/docker/settings/policies/; - curl -o fedora_tmpl.yaml https://pagure.io/fedora-infra/ansible/raw/master/f/roles/openshift-apps/greenwave/templates/fedora.yaml; - jinja2 --format=yaml -o fedora.yaml fedora_tmpl.yaml - rm fedora_tmpl.yaml - popd; - sudo docker-compose -f /home/vagrant/bodhi/devel/docker/compose-services.yml up -d -} - -alias bstopdeps="sudo docker-compose -f /home/vagrant/bodhi/devel/docker/compose-services.yml stop" - -function bremovedeps { - sudo docker-compose -f /home/vagrant/bodhi/devel/docker/compose-services.yml down --rmi all -v - rm -f /tmp/waiverdb.dump* - rm -f /home/vagrant/bodhi/devel/docker/settings/policies/* -} - -export BODHI_URL="https://bodhi-dev.example.com/" -export BODHI_OPENID_PROVIDER="https://ipsilon.tinystage.test/idp/" -export PYTHONWARNINGS="once" -export BODHI_CI_ARCHIVE_PATH="/home/vagrant/bodhi-ci-test_results/" - -cd /home/vagrant/bodhi diff --git a/devel/ansible/roles/bodhi/files/.vimrc b/devel/ansible/roles/bodhi/files/.vimrc deleted file mode 100644 index ab0fc4607c..0000000000 --- a/devel/ansible/roles/bodhi/files/.vimrc +++ /dev/null @@ -1,3 +0,0 @@ -set expandtab -set tabstop=4 -set shiftwidth=4 diff --git a/devel/ansible/roles/bodhi/files/bodhi.httpd.conf b/devel/ansible/roles/bodhi/files/bodhi.httpd.conf deleted file mode 100644 index cb09d2c41a..0000000000 --- a/devel/ansible/roles/bodhi/files/bodhi.httpd.conf +++ /dev/null @@ -1,7 +0,0 @@ -ProxyPass "/" "http://localhost:6543/" -ProxyPassReverse "/" "http://localhost:6543/" - -# Redirect to HTTPS -RewriteEngine On -RewriteCond %{HTTPS} off -RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} diff --git a/devel/ansible/roles/bodhi/files/bodhi.service b/devel/ansible/roles/bodhi/files/bodhi.service deleted file mode 100644 index c4edbbc118..0000000000 --- a/devel/ansible/roles/bodhi/files/bodhi.service +++ /dev/null @@ -1,13 +0,0 @@ -[Unit] -Description=bodhi -After=network-online.target -Wants=network-online.target - -[Service] -Environment=PYTHONWARNINGS=once VIRTUAL_ENV=/srv/venv BODHI_CONFIG=/home/vagrant/development.ini -User=vagrant -WorkingDirectory=/home/vagrant/bodhi/bodhi-server -ExecStart=/usr/bin/poetry run pserve /home/vagrant/development.ini --reload - -[Install] -WantedBy=multi-user.target diff --git a/devel/ansible/roles/bodhi/files/bodhi.toml b/devel/ansible/roles/bodhi/files/bodhi.toml deleted file mode 100644 index ae420e42ee..0000000000 --- a/devel/ansible/roles/bodhi/files/bodhi.toml +++ /dev/null @@ -1,62 +0,0 @@ -# A sample configuration for fedora-messaging. This file is in the TOML format. -# For complete details on all configuration options, see the documentation. - -amqp_url = "amqp://" - -publish_exchange = "amq.topic" - -callback = "bodhi.server.consumers:Consumer" - -# The topic_prefix configuration value will add a prefix to the topics of every sent message. -# This is used for migrating from fedmsg, and should not be used afterwards. -topic_prefix = "org.fedoraproject.dev" - -# Note the double brackets below. -# To add another binding, add another [[bindings]] section. -[[bindings]] -queue = "my_queue" -exchange = "amq.topic" -routing_keys = [ - "org.fedoraproject.*.buildsys.tag", - "org.fedoraproject.*.greenwave.decision.update", - "org.centos.*.ci.koji-build.test.running", -] - -[tls] -ca_cert = "/etc/pki/tls/certs/ca-bundle.crt" -keyfile = "/my/client/key.pem" -certfile = "/my/client/cert.pem" - -[client_properties] -app = "Bodhi" - -[queues.my_queue] -durable = true -auto_delete = false -exclusive = false -arguments = {} - -[qos] -prefetch_size = 0 -prefetch_count = 25 - -[log_config] -version = 1 -disable_existing_loggers = true - -[log_config.formatters.simple] -format = "[%(name)s %(levelname)s] %(message)s" - -[log_config.handlers.console] -class = "logging.StreamHandler" -formatter = "simple" -stream = "ext://sys.stdout" - -[log_config.loggers.fedora_messaging] -level = "INFO" -propagate = false -handlers = ["console"] - -[log_config.root] -level = "WARNING" -handlers = ["console"] diff --git a/devel/ansible/roles/bodhi/files/celery.service b/devel/ansible/roles/bodhi/files/celery.service deleted file mode 100644 index eaf21ce2b0..0000000000 --- a/devel/ansible/roles/bodhi/files/celery.service +++ /dev/null @@ -1,13 +0,0 @@ -[Unit] -Description=celery -After=network-online.target -Wants=network-online.target - -[Service] -Environment=VIRTUAL_ENV=/srv/venv BODHI_CONFIG=/home/vagrant/development.ini -User=vagrant -WorkingDirectory=/home/vagrant/bodhi/bodhi-server -ExecStart=/usr/bin/poetry run celery -A bodhi.server.tasks.app worker -l info -Q celery,has_koji_mount -B - -[Install] -WantedBy=multi-user.target diff --git a/devel/ansible/roles/bodhi/files/motd b/devel/ansible/roles/bodhi/files/motd deleted file mode 100644 index 0a019e3489..0000000000 --- a/devel/ansible/roles/bodhi/files/motd +++ /dev/null @@ -1,23 +0,0 @@ - -Welcome to the Bodhi development environment! Here are some helpful commands: - -bci: Run the Bodhi CI test suite. -bdocs: Build Bodhi's documentation. -bfedmsg: Display the log of Bodhi's messages on the bus. -blog: View Bodhi's log. (Support all the systemctl options, such as -lf) -bresetdb: Drop and reimport the database. -brestart: Restart the Bodhi service. -bodhi-shell: Get a handy python shell initialized with Bodhi models. -bstart: Start the Bodhi service. -bstop: Stop the Bodhi service. -btest: Run Bodhi's test suite. -blint: Run a series of linter checks. -bstartdeps: Create and Run WaiverDB and Greenwave docker services -bstopdeps: Stop WaiverDB and Greenwave docker services -bremovedeps: Destroy WaiverDB and Greenwave docker services - - -The BODHI_URL environment variable is set to https://bodhi-dev.example.com/ -so the bodhi client will use the local development server. - -Happy hacking! diff --git a/devel/ansible/roles/bodhi/handlers/main.yml b/devel/ansible/roles/bodhi/handlers/main.yml deleted file mode 100644 index 056d152f91..0000000000 --- a/devel/ansible/roles/bodhi/handlers/main.yml +++ /dev/null @@ -1,5 +0,0 @@ -- name: reload rabbitmq - systemd: - name: rabbitmq-server - state: restarted - daemon_reload: yes diff --git a/devel/ansible/roles/bodhi/tasks/configure_stg.yml b/devel/ansible/roles/bodhi/tasks/configure_stg.yml deleted file mode 100644 index 261158f3e9..0000000000 --- a/devel/ansible/roles/bodhi/tasks/configure_stg.yml +++ /dev/null @@ -1,42 +0,0 @@ ---- -- name: change config to use the koji buildsystem - ini_file: - path: /home/vagrant/development.ini - section: app:main - option: buildsystem - value: koji - -- name: change config to use the stg kojihub - ini_file: - path: /home/vagrant/development.ini - section: app:main - option: koji_hub - value: https://koji.stg.fedoraproject.org/kojihub - -- name: change config to use the stg koji - ini_file: - path: /home/vagrant/development.ini - section: app:main - option: koji_web_url - value: https://koji.stg.fedoraproject.org/koji/ - -- name: change config to use the stg kerberos - ini_file: - path: /home/vagrant/development.ini - section: app:main - option: krb_principal - value: "{{ staging_fas }}@STG.FEDORAPROJECT.ORG" - -- name: change config to use the pagure for acls - ini_file: - path: /home/vagrant/development.ini - section: app:main - option: acl_system - value: pagure - -- name: change config to use stg pagure for acls - ini_file: - path: /home/vagrant/development.ini - section: app:main - option: pagure_url - value: https://src.stg.fedoraproject.org/ diff --git a/devel/ansible/roles/bodhi/tasks/main.yml b/devel/ansible/roles/bodhi/tasks/main.yml deleted file mode 100644 index 66726a7bd5..0000000000 --- a/devel/ansible/roles/bodhi/tasks/main.yml +++ /dev/null @@ -1,375 +0,0 @@ ---- -- name: Install packages - dnf: - name: - - bash-completion - - cmake - - createrepo_c - - docker - - docker-compose - - expat-devel - - fedora-messaging - - freetype-devel - - gcc - - git - - graphviz - - htop - - httpie - - libffi-devel - - libjpeg-devel - - libjpeg-turbo-devel - - libxml2-devel - - make - - nmap-ncat - - openssl-devel - - pcaro-hermit-fonts - - pcp-system-tools - - pre-commit - - poetry - - postgresql-devel - - postgresql-server - - python3-alembic - - python3-arrow - - python3-authlib - - python3-backoff - - python3-bleach - - python3-bugzilla - - python3-celery - - python3-click - - python3-colander - - python3-conu - - python3-cornice - - python3-createrepo_c - - python3-devel - - python3-diff-cover - - python3-dogpile-cache - - python3-faker - - python3-flake8 - - python3-flake8-import-order - - python3-freeipa - - python3-ipdb - - python3-koji - - python3-librepo - - python3-markdown - - python3-mypy - - python3-munch - - python3-openid - - python3-pip - - python3-prometheus_client - - python3-psycopg2 - - python3-pydocstyle - - python3-pylibravatar - - python3-pymediawiki - - python3-pyramid - - python3-pyramid-fas-openid - - python3-pytest - - python3-pytest-cov - - python3-pytest-mock - - python3-responses - - python3-rpdb - - python3-setuptools - - python3-sphinx - - python3-sqlalchemy - - python3-sqlalchemy_schemadisplay - - python3-webtest - - python3-zstandard - - redhat-rpm-config - - screen - - skopeo - - tmux - - tree - - vim-enhanced - - zlib-devel - # Auth - - httpd - - mod_ssl - - ipa-client - state: present - -- name: Install krb5-devel with yum - yum: - name: krb5-devel - state: present - -- name: Initialize PostgreSQL - command: postgresql-setup initdb - args: - creates: /var/lib/pgsql/data/pg_hba.conf - -- replace: - dest: /var/lib/pgsql/data/pg_hba.conf - regexp: "host all all 127.0.0.1/32 ident" - replace: "host all all 127.0.0.1/32 trust" - -- replace: - dest: /var/lib/pgsql/data/pg_hba.conf - regexp: "host all all ::1/128 ident" - replace: "host all all ::1/128 trust" - -- service: - name: postgresql - state: started - enabled: yes - -- name: Create a database for Bodhi - shell: runuser -l postgres -c 'createdb bodhi2' && touch /home/vagrant/.db-created - args: - creates: /home/vagrant/.db-created - -# This isn't packaged in Fedora yet, but it's only a development tool (we should still add it) -- name: pip install debugtoolbar - pip: - name: pyramid_debugtoolbar - -- name: pip install jinja2-cli - pip: - name: jinja2-cli - -- name: Fake a pungi install - file: - src: /usr/bin/true - dest: /usr/bin/pungi-koji - state: link - -- name: Get Python 3 version - command: python3 -c "import sys; print('%s.%s' % sys.version_info[0:2])" - register: python3_version - -- name: Create a directory for the virtualenv - file: - name: /srv/venv - state: directory - mode: 0755 - owner: vagrant - group: vagrant - -- name: Create the virtualenv - command: virtualenv --system-site-packages /srv/venv/ - become: yes - become_user: vagrant - args: - creates: /srv/venv/bin/python - -- name: Install bodhi with poetry - command: poetry install - become: yes - become_user: vagrant - args: - chdir: /home/vagrant/bodhi/{{ item }} - environment: - VIRTUAL_ENV: /srv/venv - loop: - - bodhi-messages - - bodhi-client - - bodhi-server - -- name: Retrieve database dump - get_url: - url: https://infrastructure.fedoraproject.org/infra/db-dumps/bodhi2.dump.xz - dest: /tmp/bodhi2.dump.xz - timeout: 1000 - -- name: Import database - shell: xzcat /tmp/bodhi2.dump.xz | runuser -l postgres -c 'psql bodhi2' && touch /home/vagrant/.db-imported - args: - creates: /home/vagrant/.db-imported - -- name: Copy bodhi config file to vagrant home - command: cp /home/vagrant/bodhi/devel/development.ini.example /home/vagrant/development.ini - args: - creates: /home/vagrant/development.ini - -- name: Set bodhi config path in system env - lineinfile: - path: /etc/environment - state: present - regexp: "^{{ item.key }}=" - line: "{{ item.key }}={{ item.value}}" - with_items: - - {key: "BODHI_CONFIG", value: "/home/vagrant/development.ini"} - -- name: Adjust settings in the config - ini_file: - path: /home/vagrant/development.ini - section: app:main - option: "{{ item.key }}" - value: "{{ item.value }}" - loop: - - {key: "celery_config", value: "%(here)s/bodhi/bodhi-server/celeryconfig.py"} - - {key: "pungi.basepath", value: "%(here)s/bodhi/devel/ci/integration/bodhi/"} - - {key: "smtp_server", value: "tinystage.tinystage.test:1025"} - -- name: Creates /etc/bodhi directory - file: - path: /etc/bodhi - state: directory - -- name: Apply database migrations - become: yes - become_user: vagrant - command: poetry run alembic -c alembic.ini upgrade head - args: - chdir: /home/vagrant/bodhi/bodhi-server - environment: - VIRTUAL_ENV: /srv/venv - BODHI_CONFIG: /home/vagrant/development.ini - -- name: Install the systemd unit files - copy: - src: "{{ item }}" - dest: /etc/systemd/system/{{ item }} - mode: 0644 - with_items: - - bodhi.service - - celery.service - -- name: Install the .bashrc - copy: - src: .bashrc - dest: /home/vagrant/.bashrc - mode: 0644 - owner: vagrant - group: vagrant - -- name: Install the .vimrc - copy: - src: .vimrc - dest: /home/vagrant/.vimrc - mode: 0644 - owner: vagrant - group: vagrant - -- name: Install the motd - copy: - src: motd - dest: /etc/motd - mode: 0644 - -- name: create the composes directories - file: - path: "/srv/{{item}}" - owner: vagrant - group: vagrant - state: directory - with_items: - - composes - - composes/final - - composes/stage - -- name: Copy the fedora-messaging configuration file bodhi.toml - copy: - src: bodhi.toml - dest: /etc/fedora-messaging/config.toml - owner: root - group: root - mode: 644 - -- name: Link the bodhi bash completion script - file: - src: /home/vagrant/bodhi/bodhi-client/bodhi-client.bash - dest: /etc/bash_completion.d/bodhi-client.bash - state: link - -# Auth - -- name: Enroll system as IPA client - shell: - cmd: ipa-client-install --hostname {{ ansible_fqdn }} --domain tinystage.test --realm {{ krb_realm }} --server ipa.tinystage.test -p {{ ipa_admin_user }} -w {{ ipa_admin_password }} -U -N --force-join - creates: /etc/ipa/default.conf - -- name: pip install oidc-register - pip: - name: oidc-register - executable: pip3 - -- name: Get the content of the CA cert - slurp: - src: /etc/ipa/ca.crt - register: ca_crt - -- name: Put tinystage root CA in the list of CA's - blockinfile: - block: "{{ ca_crt.content | b64decode }}" - path: "{{ item }}" - loop: - - /etc/pki/tls/certs/ca-bundle.crt - - /usr/local/lib/python{{ python3_version.stdout }}/site-packages/httplib2/cacerts.txt - - /srv/venv/lib/python{{ python3_version.stdout }}/site-packages/certifi/cacert.pem - -- name: Register with Ipsilon - command: python3 /home/vagrant/bodhi/devel/register-with-ipsilon.py - register: _ipsilon_registration - -- name: Generate and get SSL cert - shell: - cmd: ipa-getcert request -f /etc/pki/tls/certs/server.pem -k /etc/pki/tls/private/server.key -K HTTP/{{ ansible_fqdn }} -N {{ ansible_fqdn }} - creates: /etc/pki/tls/certs/server.pem - -- name: Check the cert is there - wait_for: - path: /etc/pki/tls/certs/server.pem - state: present - -- name: Check the key is there - wait_for: - path: /etc/pki/tls/private/server.key - state: present - -- name: Setup mod_ssl - lineinfile: - path: /etc/httpd/conf.d/ssl.conf - regexp: "^SSLCertificateFile " - line: SSLCertificateFile /etc/pki/tls/certs/server.pem -- name: Setup mod_ssl - lineinfile: - path: /etc/httpd/conf.d/ssl.conf - regexp: "^SSLCertificateKeyFile " - line: SSLCertificateKeyFile /etc/pki/tls/private/server.key -- name: Setup mod_ssl - lineinfile: - path: /etc/httpd/conf.d/ssl.conf - insertbefore: "" - regexp: "^RequestHeader set X-Forwarded-Proto https$" - line: RequestHeader set X-Forwarded-Proto https - -- name: Copy the create users and groups script - template: - src: create-freeipa-users-grps.py - dest: /home/vagrant/create-freeipa-users-grps.py - mode: 0644 - owner: vagrant - group: vagrant - -- name: Add development users to tinystage - shell: python create-freeipa-users-grps.py > users-creation.log - args: - chdir: /home/vagrant/ - creates: users-creation.log - -- name: Setup httpd - copy: - src: bodhi.httpd.conf - dest: /etc/httpd/conf.d/bodhi.conf - -- name: Allow apache to reverse proxy - seboolean: - name: httpd_can_network_connect - state: yes - persistent: yes - - -- name: Start and enable the bodhi-related services - service: - name: "{{ item }}" - state: restarted - enabled: yes - with_items: - - bodhi - - docker - - celery - -- name: Start enable httpd - service: - name: httpd - state: restarted - enabled: yes diff --git a/devel/ansible/roles/bodhi/templates/create-freeipa-users-grps.py b/devel/ansible/roles/bodhi/templates/create-freeipa-users-grps.py deleted file mode 100644 index 7fb2fdee9f..0000000000 --- a/devel/ansible/roles/bodhi/templates/create-freeipa-users-grps.py +++ /dev/null @@ -1,58 +0,0 @@ -from faker import Faker - -import python_freeipa - -USER_PASSWORD = "password" - -fake = Faker() -fake.seed_instance(0) - -ipa = python_freeipa.ClientLegacy( - host="ipa.tinystage.test", verify_ssl="/etc/ipa/ca.crt" -) -ipa.login("admin", "password") - -untouched_ipa = python_freeipa.ClientLegacy( - host="ipa.tinystage.test", verify_ssl="/etc/ipa/ca.crt" -) - -for group in ["packager", "provenpackager"]: - if ipa.group_find(cn=group).get('result') != []: - print(f"group {group} is already in tinystage") - continue - ipa.group_add(group, f"A group for {group}", fasgroup=True) - ipa._request("fasagreement_add_group", "FPCA", {"group": group}) - -for username in ["tinystage_packager", "tinystage_provenpackager", "{{ fas_username }}"]: - if username == "": - continue - if ipa.user_find(uid=username).get('result') != []: - print(f"user {username} is already in tinystage") - continue - firstName = fake.first_name() - lastName = fake.last_name() - fullname = firstName + " " + lastName - print(f"adding user {username} - {fullname}") - try: - ipa.user_add( - username, - firstName, - lastName, - fullname, - disabled=False, - user_password=USER_PASSWORD, - fasircnick=[username, username + "_"], - faslocale="en-US", - fastimezone="Australia/Brisbane", - fasstatusnote="active", - fasgpgkeyid=[], - ) - untouched_ipa.change_password( - username, new_password=USER_PASSWORD, old_password=USER_PASSWORD - ) - ipa._request("fasagreement_add_user", "FPCA", {"user": username}) - ipa.group_add_member("packager", username) - if username == "tinystage_provenpackager": - ipa.group_add_member("provenpackager", username) - except python_freeipa.exceptions.FreeIPAError as e: - print(e) diff --git a/devel/ansible/roles/rabbitmq/files/local-rabbitmq.te b/devel/ansible/roles/rabbitmq/files/local-rabbitmq.te deleted file mode 100644 index 09a6d6f551..0000000000 --- a/devel/ansible/roles/rabbitmq/files/local-rabbitmq.te +++ /dev/null @@ -1,17 +0,0 @@ -# https://bugzilla.redhat.com/show_bug.cgi?id=2020278#c6 - -module local-rabbitmq 1.0; - -require { - type init_var_run_t; - type rabbitmq_t; - type tmpfs_t; - class file { execute map read write }; - class process execmem; - class sock_file { getattr read }; -} - -#============= rabbitmq_t ============== -allow rabbitmq_t init_var_run_t:sock_file { getattr read }; -allow rabbitmq_t self:process execmem; -allow rabbitmq_t tmpfs_t:file { execute map read write }; diff --git a/devel/ansible/roles/rabbitmq/files/print-messages.service b/devel/ansible/roles/rabbitmq/files/print-messages.service deleted file mode 100644 index 8f88d4fb92..0000000000 --- a/devel/ansible/roles/rabbitmq/files/print-messages.service +++ /dev/null @@ -1,11 +0,0 @@ -[Unit] -Description=Print messages sent to the amq.topic exchange -After=network-online.target -Wants=network-online.target - -[Service] -User=vagrant -ExecStart=/usr/bin/fedora-messaging consume --callback="fedora_messaging.example:printer" - -[Install] -WantedBy=multi-user.target diff --git a/devel/ansible/roles/rabbitmq/tasks/main.yml b/devel/ansible/roles/rabbitmq/tasks/main.yml deleted file mode 100644 index ad949a2ab0..0000000000 --- a/devel/ansible/roles/rabbitmq/tasks/main.yml +++ /dev/null @@ -1,80 +0,0 @@ -- name: Install RabbitMQ packages - package: - name: "{{ item }}" - state: present - with_items: - - rabbitmq-server - - fedora-messaging - -# SELinux -- name: compile policy module - command: checkmodule -o local-rabbitmq.mod -m -M /home/vagrant/bodhi/devel/ansible/roles/rabbitmq/files/local-rabbitmq.te - args: - creates: local-rabbitmq.mod - -- name: package policy module - command: semodule_package -o local-rabbitmq.pp -m local-rabbitmq.mod - args: - creates: local-rabbitmq.pp - -- name: install policy module - command: semodule -i local-rabbitmq.pp - args: - creates: /var/lib/selinux/targeted/active/modules/400/local-rabbitmq/ - -- name: Create RabbitMQ systemd override directory - file: - path: /etc/systemd/system/rabbitmq-server.service.d/ - state: directory - -- name: Override file limit on rabbitmq - copy: - content: "[Service]\nLimitNOFILE={{rabbitmq_cluster_file_limit}}\n" - dest: /etc/systemd/system/rabbitmq-server.service.d/override.conf - notify: - - reload rabbitmq - -- name: Start rabbitmq - service: - name: rabbitmq-server - state: started - enabled: yes - -- name: Enables the rabbitmq management and SSL authentication plugins - rabbitmq_plugin: - names: rabbitmq_management,rabbitmq_auth_mechanism_ssl - notify: - - reload rabbitmq - -- name: Ensure default vhost exists - rabbitmq_vhost: - name: / - state: present - -- name: Create a guest user in RabbitMQ - rabbitmq_user: - user: guest - password: guest - tags: administrator - vhost: / - configure_priv: .* - read_priv: .* - write_priv: .* - state: present - -- name: Install the systemd unit files - copy: - src: "{{ item }}" - dest: /etc/systemd/system/{{ item }} - mode: 0644 - with_items: - - print-messages.service - -- name: Start and enable the rabbitmq-related services - service: - name: "{{ item }}" - state: restarted - enabled: yes - with_items: - - fm-consumer@config - - print-messages diff --git a/devel/development.ini.example b/devel/development.ini.example index 5108928c8a..4d97cdede6 100644 --- a/devel/development.ini.example +++ b/devel/development.ini.example @@ -76,7 +76,7 @@ pungi.conf.rpm = pungi.rpm.conf.j2 pungi.conf.module = pungi.module.conf.j2 test_gating.required = True -# WaiverDB and Greenwave in vagrant are provided via docker local services +# WaiverDB and Greenwave in development environment are provided by containers waiverdb_api_url = http://bodhi_user:pass@localhost:6544/api/v1.0 greenwave_api_url = http://localhost:6545/api/v1.0 diff --git a/devel/docker/compose-services.yml b/devel/docker/compose-services.yml deleted file mode 100644 index 0986584e32..0000000000 --- a/devel/docker/compose-services.yml +++ /dev/null @@ -1,54 +0,0 @@ -version: '3' -services: - wdb: - image: postgres:latest - container_name: waiverdb_database - restart: always - expose: - - "5432" - volumes: - - ./settings/restore_waiverdb.sh:/docker-entrypoint-initdb.d/restore_db.sh - - /tmp/waiverdb.dump:/docker-entrypoint-initdb.d/wdb_pgdata - healthcheck: - test: ["CMD-SHELL", "pg_isready -h localhost -U waiverdb -d waiverdb"] - interval: 5s - timeout: 30s - retries: 3 - - waiverdb: - image: "quay.io/factory2/waiverdb:latest" - container_name: waiverdb_service - entrypoint: /bin/sh -i -c "waiverdb wait-for-db && waiverdb db upgrade && /usr/bin/gunicorn-3 --bind 0.0.0.0:6544 --access-logfile=- --enable-stdio-inheritance waiverdb.wsgi:app" - volumes: - - ./settings/waiverdb-settings.py:/etc/waiverdb/settings.py - ports: - - "6544:6544" - user: '0' - depends_on: - - wdb - healthcheck: - test: ["CMD", "curl", "-f", "http://localhost:6544/healthcheck"] - interval: 5s - timeout: 30s - retries: 3 - - greenwave: - image: "quay.io/factory2/greenwave:latest" - container_name: greenwave_service - entrypoint: ["/bin/sh", "-c", "gunicorn-3 --workers 8 --bind 0.0.0.0:6545 --access-logfile=- --error-logfile=- --enable-stdio-inheritance greenwave.wsgi:app"] - volumes: - - ./settings/greenwave-settings.py:/etc/greenwave/settings.py - - ./settings/policies:/etc/greenwave/policies/ - ports: - - "6545:6545" - depends_on: - - waiverdb - healthcheck: - test: ["CMD", "curl", "-f", "http://localhost:6545/api/v1.0/about"] - interval: 5s - timeout: 30s - retries: 3 - -networks: - default: - driver: bridge diff --git a/devel/docker/settings/greenwave-settings.py b/devel/docker/settings/greenwave-settings.py deleted file mode 100644 index fd786833fc..0000000000 --- a/devel/docker/settings/greenwave-settings.py +++ /dev/null @@ -1,15 +0,0 @@ -HOST = '0.0.0.0' -PORT = 6545 -DEBUG = False -POLICIES_DIR = '/etc/greenwave/policies/' -DIST_GIT_BASE_URL = 'https://src.fedoraproject.org' -DIST_GIT_URL_TEMPLATE = '{DIST_GIT_BASE_URL}/{pkg_namespace}/{pkg_name}/raw/{rev}/f/gating.yaml' -KOJI_BASE_URL = 'https://koji.fedoraproject.org/kojihub' - -SECRET_KEY = 'this-is-only-for-development' -WAIVERDB_API_URL = 'http://waiverdb:6544/api/v1.0' -RESULTSDB_API_URL = 'https://resultsdb.fedoraproject.org/api/v2.0' -CORS_URL = '*' -CACHE = { - "backend": "dogpile.cache.memory_pickle", -} diff --git a/devel/docker/settings/restore_waiverdb.sh b/devel/docker/settings/restore_waiverdb.sh deleted file mode 100755 index a427228af5..0000000000 --- a/devel/docker/settings/restore_waiverdb.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -set -e - -psql -U postgres -c "CREATE USER waiverdb CREATEDB;" -psql -U postgres -f /docker-entrypoint-initdb.d/wdb_pgdata diff --git a/devel/docker/settings/waiverdb-settings.py b/devel/docker/settings/waiverdb-settings.py deleted file mode 100644 index 107ff18ef9..0000000000 --- a/devel/docker/settings/waiverdb-settings.py +++ /dev/null @@ -1,11 +0,0 @@ -DATABASE_URI = 'postgresql+psycopg2://waiverdb@wdb:5432/waiverdb' -RESULTSDB_API_URL = 'https://resultsdb.fedoraproject.org/api/v2.0' -SECRET_KEY = 'this-is-only-for-development' -CORS_URL = '*' - -# MESSAGE_BUS_PUBLISH = True -MESSAGE_BUS_PUBLISH = False - -AUTH_METHOD = 'dummy' -SUPERUSERS = ['bodhi_user'] -PORT = 6544 diff --git a/devel/register-with-ipsilon.py b/devel/register-with-ipsilon.py deleted file mode 100755 index 79b6c9a18e..0000000000 --- a/devel/register-with-ipsilon.py +++ /dev/null @@ -1,69 +0,0 @@ -#!/usr/bin/env python3 - -from argparse import ArgumentParser -from configparser import ConfigParser -import os -import sys - -from oidc_register import discovery, registration - - -REDIRECT_URI = "https://bodhi-dev.example.com/oidc/authorize" -PROVIDER_URL = "https://ipsilon.tinystage.test/idp/openidc/" -PLACEHOLDERS = { - "client_id": "oidc-client_id", - "client_secret": "oidc-client_secret", -} - - -def main(): - parser = ArgumentParser(description='Register Bodhi Server with an OIDC provider.') - parser.add_argument( - "config_file", - nargs="?", - default="/home/vagrant/development.ini", - help="Bodhi server's configuration file", - ) - args = parser.parse_args() - if not os.path.exists(args.config_file): - print(f"No such file: {args.config_file}", file=sys.stderr) - sys.exit(1) - config = ConfigParser() - config.read(args.config_file) - for confkey in ("client_id", "client_secret"): - if config["app:main"][f"oidc.fedora.{confkey}"] != PLACEHOLDERS[confkey]: - print("Bodhi is already registered, aborting.") - return - - registration.check_redirect_uris([REDIRECT_URI]) - try: - OP = discovery.discover_OP_information(PROVIDER_URL) - except Exception as ex: - print('Error discovering OP information', file=sys.stderr) - print(ex, file=sys.stderr) - sys.exit(1) - - if 'registration_endpoint' not in OP: - print('Provider does not support dynamic client registration', file=sys.stderr) - print(OP, file=sys.stderr) - sys.exit(1) - - try: - reg_info = registration.register_client(OP, [REDIRECT_URI]) - except Exception as ex: - print('Error registering client') - print(ex) - sys.exit(1) - - config["app:main"]["oidc.fedora.client_id"] = reg_info["web"]["client_id"] - config["app:main"]["oidc.fedora.client_secret"] = reg_info["web"]["client_secret"] - config["app:main"]["oidc.fedora.server_metadata_url"] = \ - f'{reg_info["web"]["issuer"]}.well-known/openid-configuration' - - with open(args.config_file, "w") as config_file: - config.write(config_file) - print("Bodhi is now registered with Ipsilon.") - - -if __name__ == "__main__": - main() diff --git a/docs/developer/bcd.rst b/docs/developer/bcd.rst index 41d78d033e..66840bf1d5 100644 --- a/docs/developer/bcd.rst +++ b/docs/developer/bcd.rst @@ -94,5 +94,33 @@ You can shell into the running Bodhi container like this:: Note the container must be running, or this will fail. Once you are inside the development environment, there are a helpful set of commands in your ``.bashrc`` that will be printed to the -screen via the ``/etc/motd`` file. These work exactly as documented in :ref:`the Vagrant doc `, -except that ``bci`` is not available in this environment (as we can't nest containers like that). +screen via the ``/etc/motd`` file. Be sure to familiarize yourself with these: + +.. include:: ../../devel/ansible-podman/containers/bodhi/motd + :literal: + +The code from your development host will be mounted in ``/bodhi`` in the Bodhi container. +You can edit this code on the host, and the changes will automatically be reflected in the container. + +The development server is run inside the container by the ``bodhi.service`` systemd unit. +You can use ``bodhi-shell`` to get a Python shell quickly set up with a nice environment for you to hack +in. Here's an example where we use ``bodhi-shell`` to set an update's request to stable:: + + [root@bodhi-dev bodhi]# bodhi-shell + Python 3.12.0 (main, Oct 2 2023, 00:00:00) [GCC 13.2.1 20230918 (Red Hat 13.2.1-3)] on linux + Type "help" for more information. + + Environment: + app The WSGI application. + registry Active Pyramid registry. + request Active request object. + root Root of the default resource tree. + root_factory Default root factory used to create `root`. + + Custom Variables: + m bodhi.server.models + s bodhi.server.Session + + >>> u = m.Update.query.filter_by(alias='FEDORA-2016-840ff89708').one() + >>> u.request = m.UpdateRequest.stable + >>> s().commit() diff --git a/docs/developer/bcd_vscode.rst b/docs/developer/bcd_vscode.rst new file mode 100644 index 0000000000..28b15f45f0 --- /dev/null +++ b/docs/developer/bcd_vscode.rst @@ -0,0 +1,76 @@ +================================= +Debugging with Visual Studio Code +================================= + +Visual Studio Code's `Dev Containers ` extension may be able to use the environment provided by Vagrant, +with support for discovering, running and debugging unit-tests. The person who implemented BCD +doesn't use VS Code, so we don't really know. Please try it and tell us, then we can make this +doc better. + +This provides an IDE alternative to running `btest` from `./bcd shell`. + +This assumes you have working environment as described in :doc:`BCD - the Bodhi Container Development environment ` + +Configure VS Code for BCD +========================= + +Since BCD uses podman, `this handy guide from Stack Overflow ` should help. +You want to start the BCD containers as described in the BCD page, then set up podman so VS Code will be able to see it +(as explained on the SO question), then finally have VS Code attach to the running bodhi-dev-bodhi container. The upstream +VS Code docs explain that to attach to a running container, you should either select Dev Containers: Attach to Running Container +from the Command Palette (F1) or use the Remote Explorer in the Activity Bar and from the Containers view, select the +Attach to Container inline action on the container you want to connect to. + +Again, we haven't tried this. Sorry. Let us know how it goes. The following instructions are preserved mostly unmodified +from when this page documented using VS Code with Vagrant. They're probably still more or less relevant to BCD. + +Debugging application running in BCD +==================================== + +When inside the container set the debug configuration in `launch.json` for Pyramid (you should get the pyramid conf as a suggestion):: + + { + "version": "0.2.0", + "configurations": [ + { + "name": "Python: Pyramid Application", + "type": "python", + "request": "launch", + "module": "pyramid.scripts.pserve", + "args": [ + "/home/vagrant/development.ini" + ], + "pyramid": true, + "jinja": false, + }, + +When you want to start application for debugging, you first need to run `systemctl stop bodhi` in the container shell, +otherwise the debugger will complain about ports already in use, as it will launch another instance of bodhi inside of the application. + +After you stopped the bodhi service, you can run the "Python: Pyramid Application" from the Debug pane (Ctrl+Shift+D) and +the application will stop on breakpoints. + +Debugging unit-tests +==================== + +For running unit-tests install `Python Test Explorer for Visual Studio Code ` extension +Open settings (CTRL+Comma), and in the settings for the container, swith to JSON view and make the following configuration changes:: + + { + "python.testing.pytestEnabled": true, + "python.testing.pytestPath": "py.test-3", + "pythonTestExplorer.testFramework": "pytest", + "python.pythonPath": "python3", + "python.testing.pytestArgs": ["--no-cov"] + } + +Currently coverage reporting and debugging don't work at the same time, due to a reported issue. +Currently suggested workaround is to disable the coverage-reporting with `--no-cov` parameter. +The issue is currently tracked in https://github.com/microsoft/vscode-python/issues/693 + +After configuring you should be able to populate the test-explorer with unit tests and start debugging! + +Debugging celery +================ +If you want to debug code running in the celery worker, you first need to stop the celery service and then start celery from inside vs-code, +in similar fashion as you'd run `pserve` in previous example. diff --git a/docs/developer/index.rst b/docs/developer/index.rst index 1761fcdca0..0c358dd092 100644 --- a/docs/developer/index.rst +++ b/docs/developer/index.rst @@ -13,18 +13,16 @@ Before you submit a pull request to Bodhi, please ensure that it meets these cri * All tests must pass. * New code must have 100% test coverage. This one is particularly important, as we don't want to deploy any broken code into production. At the end of ``btest`` run, you can see your code coverage. - If you are not using Vagrant environment you can check the code coverage by running + If you are not using BCD environment you can check the code coverage by running ``diff-cover coverage.xml --compare-branch=origin/develop --fail-under=100``. * New functions, methods, and classes must have docblocks that explain what the code block is, and describing any parameters it accepts and what it returns (if anything). You can use the - ``pydocstyle`` utility to automatically check your code for this. You can also run ``pydocstyle bodhi`` - in Vagrant. -* Parameter and return value types should be declared using `type hints`_. You can test this by running - ``bci mypy`` in Vagrant. + ``pydocstyle`` utility to automatically check your code for this. You can also run ``pydocstyle /bodhi`` + in BCD. +* Parameter and return value types should be declared using `type hints`_. * New code must follow `PEP-8 `_. You can use the - ``flake8`` utility to automatically check your code. Alternatively you can run ``flake8-3`` - in Vagrant. -* If you want to run the three above at once you can use ``blint`` alias in Vagrant. + ``flake8`` utility to automatically check your code. +* If you want to run the three above at once you can use ``blint`` alias in BCD. * Make sure your commits are atomic. With only rare exceptions, each improvement or bug fix should have exactly one commit. This makes it much easier to peruse the git history to find out which changes relate to a feature or bugfix implementation, and is particularly valuable when commits @@ -160,20 +158,14 @@ failure, I can execute the script like this:: $ sudo devel/ci/bodhi-ci all -r f28 -r f29 -x -Note that if you are using the Vagrant development environment, there is a handy ``bci`` shell alias -that runs ``sudo devel/ci/bodhi-ci`` for you. - Create a Bodhi development environment ====================================== -You can use Bodhi's "BCD" container-based development environment, or use Vagrant to create a VM- -based development environment. Using a local Python virtualenv is no longer supported. See the -:doc:`BCD Guide ` for instructions on using BCD, or the :doc:`Bodhi Vagrant Guide ` -for instructions on using Vagrant. +You can use Bodhi's "BCD" container-based development environment. Using Vagrant or a local Python +virtualenv are no longer supported. See the :doc:`BCD Guide ` for instructions on using BCD. -You can configure Visual Studio Code to run unit-tests inside with :doc:`Bodhi Vagrant - VS Code Guide `. +You can configure Visual Studio Code to run unit-tests inside with :doc:`Bodhi BCD - VS Code Guide `. .. _docs/user/release_notes.rst: https://github.com/fedora-infra/bodhi/blob/develop/docs/user/release_notes.rst#release-notes .. _type hints: https://docs.python.org/3/library/typing.html -.. _Vagrant: https://www.vagrantup.com diff --git a/docs/developer/vagrant.rst b/docs/developer/vagrant.rst deleted file mode 100644 index 953bb074b8..0000000000 --- a/docs/developer/vagrant.rst +++ /dev/null @@ -1,118 +0,0 @@ -======= -Vagrant -======= - -`Vagrant`_ allows contributors to get quickly up and running with a Bodhi development environment by -automatically configuring a virtual machine. Before you get started, ensure that your host machine -has virtualization extensions enabled in its BIOS so the guest is not slow. To -get started, simply use these commands:: - - $ sudo dnf install ansible libvirt vagrant-libvirt vagrant-sshfs vagrant-hostmanager - $ sudo systemctl enable libvirtd - $ sudo systemctl start libvirtd - -As of 2022, bodhi now uses OpenID Connect (OIDC) for authentication. For the vagrant development environment, -this requires a running FreeIPA and Ipsilon instance. Running tinystage -(https://github.com/fedora-infra/tiny-stage) will set these up. Ensure that tinystage is running before trying -to provision bodhi with vagrant. To set up tinystage:: - - $ git clone https://github.com/fedora-infra/tiny-stage - $ pushd tiny-stage/ - $ vagrant up - $ popd - -Next, check out the bodhi code and run ``vagrant up``:: - - $ git clone https://github.com/fedora-infra/bodhi - $ cd bodhi - $ vagrant up - -Your newly provisioned bodhi development instance is now available at https://bodhi-dev.example.com/. - -The Vagrant guest runs an AMQP message broker (RabbitMQ) which has a web interface for monitoring and -administration of the Fedora Messaging queue at http://bodhi-dev.example.com:15672/. The default username -is ``guest`` and the password is ``guest``. - - -.. _Vagrant: https://www.vagrantup.com - - -Authentication -^^^^^^^^^^^^^^ - -The Vagrant environment will configure Bodhi server and Bodhi's CLI to use the tiny-stage Ipsilon -(https://ipsilon.tinystage.test) for authentication. The users are defined in the tiny-stage FreeIPA -instance (https://ipa.tinystage.test). There are many test users defined by default in the tinystage -FreeIPA instance, and the admin user is ``admin`` with a password ``password``. - -During the Vagrant provisioning, two users are automatically added to the tinystage instance specifically -for enabling you to test Bodhi: ``tinystage_packager`` and ``tinystage_provenpackager``, both with -password ``password``. If you want to login with your username (or any username of your choice), just -edit the ``fas_username`` variable in the Vagrantfile and re-provision the VM. Be advised that this will -not be a copy of your real fas account, it will just have the same username with the default password -``password`` and fake complementary data. - -.. _vagrant-tips: - -Quick tips about the Bodhi Vagrant environment -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - - -You can ssh into your running Vagrant box like this:: - - # Make sure your bodhi checkout is your shell's cwd - $ vagrant ssh - -Once you are inside the development environment, there are a helpful set of commands in your -``.bashrc`` that will be printed to the screen via the ``/etc/motd`` file. Be sure to familiarize -yourself with these: - -.. include:: ../../devel/ansible/roles/bodhi/files/motd - :literal: - -Keep in mind that all ``vagrant`` commands should be run with your current working directory set to -your Bodhi checkout. The code from your development host will be mounted in ``/home/vagrant/bodhi`` -in the guest. You can edit this code on the host, and the vagrant-sshfs plugin will cause the -changes to automatically be reflected in the guest's ``/home/vagrant/bodhi`` folder. - -The development server is run inside the Vagrant environment by the ``bodhi.service`` systemd unit. -You can use ``bodhi-shell`` to get a Python shell quickly set up with a nice environment for you to hack -in. Here's an example where we use ``bodhi-shell`` to set an update's request to stable:: - - [vagrant@bodhi-dev bodhi]$ bodhi-shell - 2017-11-02 21:08:56,359 INFO [bodhi][MainThread] Using the FakeBugTracker - 2017-11-02 21:08:56,359 DEBUG [bodhi][MainThread] Using DevBuildsys - Python 2.7.13 (default, May 10 2017, 20:04:28) - Type "copyright", "credits" or "license" for more information. - - IPython 3.2.1 -- An enhanced Interactive Python. - ? -> Introduction and overview of IPython's features. - %quickref -> Quick reference. - help -> Python's own help system. - object? -> Details about 'object', use 'object??' for extra details. - - Environment: - app The WSGI application. - registry Active Pyramid registry. - request Active request object. - root Root of the default resource tree. - root_factory Default root factory used to create `root`. - - Custom Variables: - m bodhi.server.models - s bodhi.server.Session - - In [1]: u = m.Update.query.filter_by(alias='FEDORA-2016-840ff89708').one() - - In [2]: u.request = m.UpdateRequest.stable - - In [3]: s().commit() - -When you are done with your Vagrant guest, you can destroy it permanently by running this command on -the host:: - - $ vagrant destroy - -If you wish to use a custom ``Vagrantfile``, you can set the environment variable -``VAGRANT_VAGRANTFILE`` as a path to a script. - diff --git a/docs/developer/vagrant_vscode.rst b/docs/developer/vagrant_vscode.rst deleted file mode 100644 index 4cdb534559..0000000000 --- a/docs/developer/vagrant_vscode.rst +++ /dev/null @@ -1,88 +0,0 @@ -============================================ -Debugging with Visual Studio Code -============================================ - -Visual Studio Code with its Remote - SSH extension can utilize the environment provided by Vagrant, -with support for discovering, running and debugging unit-tests. - -This provides an IDE alternative to running `btest` from `vagrant ssh` shell. - -This assumes you have working environment as described in :doc:`Bodhi Vagrant Guide ` - -Configure VS Code for Remote SSH -================================ - -To configure VS Code to access Vagrant Environment you first need to install the `Remote - SSH ` extension - -Get the ssh configuration for connecting to the vagrant-box:: - - $ vagrant ssh-config - Host bodhi - HostName 192.168.122.225 - User vagrant - Port 22 - UserKnownHostsFile /dev/null - StrictHostKeyChecking no - PasswordAuthentication no - IdentityFile ~/work/bodhi/.vagrant/machines/bodhi/libvirt/private_key - IdentitiesOnly yes - LogLevel FATAL - -If you have only one vagrant-box running, you should be able to just copy the configuration to your `~/.ssh/config` and test it:: - - $ ssh bodhi - Welcome to the Bodhi development environment! Here are some helpful commands: - -In Visual Studio Code, press F1 and run the `Remote-SSH: Open SSH Host...`, you should be prompted for a ssh command, -if you have `~/.ssh/config` setup, using `ssh bodhi` should be sufficient. Now you can connect to the vagrant box with VS Code. - -Debugging application running in Vagrant -======================================== - -When inside the SSH remote set the debug configuration in `launch.json` for Pyramid (you should get the pyramid conf as a suggestion):: - - { - "version": "0.2.0", - "configurations": [ - { - "name": "Python: Pyramid Application", - "type": "python", - "request": "launch", - "module": "pyramid.scripts.pserve", - "args": [ - "/home/vagrant/development.ini" - ], - "pyramid": true, - "jinja": false, - }, - -When you want to start application for debugging, you first need to run `sudo systemctl stop bodhi` in the vagrant's shell, -otherwise the debugger will complain about ports already in use, as it will launch another instance of bodhi inside of the application. - -After you stopped the bodhi service, you can run the "Python: Pyramid Application" from the Debug pane (Ctrl+Shift+D) and -the application will stop on breakpoints. - -Debugging unit-tests -=========================== - -For running unit-tests install `Python Test Explorer for Visual Studio Code ` extension -Open settings (CTRL+Comma), and in the settings for the SSH Remote, swith to JSON view and make the following configuration changes:: - - { - "python.testing.pytestEnabled": true, - "python.testing.pytestPath": "py.test-3", - "pythonTestExplorer.testFramework": "pytest", - "python.pythonPath": "python3", - "python.testing.pytestArgs": ["--no-cov"] - } - -Currently coverage reporting and debugging don't work at the same time, due to a reported issue. -Currently suggested workaround is to disable the coverage-reporting with `--no-cov` parameter. -The issue is currently tracked in https://github.com/microsoft/vscode-python/issues/693 - -After configuring you sould be able to populate the test-explorer with unit-tests and start debugging :-) - -Debugging celery -=========================== -If you want to debug code running in hte celery worker, you first need to stop the celery service and then start celery from inside vs-code, -in simmilar fashion as you'd run `pserve` in previous example. diff --git a/docs/index.rst b/docs/index.rst index feb4ac7599..54e1c4afa7 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -62,8 +62,7 @@ Contributor Guide developer/index developer/releases developer/bcd - developer/vagrant - developer/vagrant_vscode + developer/bcd_vscode developer/models diff --git a/news/5600.dev b/news/5600.dev new file mode 100644 index 0000000000..dde25c24b4 --- /dev/null +++ b/news/5600.dev @@ -0,0 +1 @@ +The Vagrant development environment is entirely removed in favor of BCD, and bodhi-shell is fixed in BCD.