Skip to content

bitbucket repositories

We have our source code on a free bitbucket account, and there is also a working pipeline in action for the doc site.

code repository

The repository is located here :

https://bitbucket.org/keesklopt/workspace/overview

Almost all projects are copied there. Lot's of them are half-finished.

pipeline

The documentation was created with sphinx-doc in the earlier days. But a new framework called mkdocs was discovered later.

The result from that package is much better looking and also the .md markdown entry is much easier to remember. The documentation itself is hosted on a strato server with the domain name nduss.nl.

http://www.nduss.nl

The pipeline for generating this documentation is fully automatic on bitbucket.

The pipeline is implemented in the file bitbucket-pipelines.yml, bitbucket recognizes that and will start the pipeline.

#  Template python-build

#  This template allows you to validate your python code.
#  The workflow allows running tests and code linting on the default branch.

#image: python:3.8
image: debian:bullseye

pipelines:
  default:
    - parallel:
      - step:
          name: Build
          caches:
            - pip
          script:
            - apt-get update
            - apt-get install -y sshpass python3-pip
            - cd klopt
            - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
            - mkdocs build
            - tar -zcvf site.tar.gz site
            - chmod -v 700 $(pwd)
            - echo "${ANSIBLE_VAULT_PASS}" > .vault\_password.txt
            - ansible-playbook playbook.yml

The pipeline will create a docker image to build the site in. The steps are simple

  • checkout the code (implied, this is inside the docs repository tree)
  • install software
  • build the site with mkdocs
  • tar the site
  • use ansible to unpack the site on nduss.nl

The magic is in the ANSIBLE_VAULT_PASS variable set in the bitbucket repository.

https://bitbucket.org/keesklopt/doc/src , click "repository setting" (left menu). -> click "Repository variables" and you will see the variable, but you cannot see the value. (it is in ~/_private/accounts.cpt as well).

This password can be used to open the vault :

ansible-vault edit vars/vault.yml

This will show you the ssh and sudo password that are needed to make ansible run on the remote host.

work instruction install doc site

Check out the source code and fire up the mkdocs server.

git clone git@bitbucket.org:keesklopt/doc.git
cd doc/klopt
mkdocs serve

For installing mkdocs see : https://www.mkdocs.org/getting-started/ and the nduss site itself http://www.nduss.nl

If installed you will get a browser window popup with automatic reload to check your changes.

If finished you can install you changes on the nduss.nl website with

# look up the password in ~/\_private/accounts.cpt
echo "correct\_password" > .vault\_password.txt
# for completeness, you need sshpass :
sudo apt-get install sshpass
ansible-playbook playbook.ini

But as seen in the previous chapter, you could just commit it to the repository for the pipeline to pick it up.