Skip to content

Instantly share code, notes, and snippets.

@lattice0
Last active August 7, 2022 05:46
Show Gist options
  • Select an option

  • Save lattice0/ac47e45d8b781d06e0c777b626951df6 to your computer and use it in GitHub Desktop.

Select an option

Save lattice0/ac47e45d8b781d06e0c777b626951df6 to your computer and use it in GitHub Desktop.

Revisions

  1. lattice0 revised this gist Aug 7, 2022. 1 changed file with 12 additions and 0 deletions.
    12 changes: 12 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -100,3 +100,15 @@ sudo usermod -aG docker gitlab-runner
    # Verify that it works (that is, the runner can access docker)

    sudo -u gitlab-runner -H docker info

    Vagrant files:

    Vagrant.configure("2") do |config|
    config.vm.box = "ubuntu/jammy64"
    config.vm.define "ubuntu"
    config.vm.hostname = "ubuntu"
    config.vm.provider "virtualbox" do |vb|
    vb.name = "ubuntu"
    end
    end

  2. lattice0 revised this gist Aug 7, 2022. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -73,6 +73,8 @@ session_timeout = 1800

    Also add the cache directory to the runners section
    cache_dir = "/home/your_username/cache"
    output_limit = 90000


    example:

    @@ -82,6 +84,7 @@ example:
    token = "..."
    executor = "virtualbox"
    cache_dir = "/home/lz/cache"
    output_limit = 90000



  3. lattice0 revised this gist Aug 7, 2022. 1 changed file with 14 additions and 0 deletions.
    14 changes: 14 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -71,6 +71,20 @@ session_timeout = 1800
    password = ""
    disable_strict_host_key_checking = true

    Also add the cache directory to the runners section
    cache_dir = "/home/your_username/cache"

    example:

    [[runners]]
    name = "virtualbox_nondocker"
    url = "http://192.168.1.20/"
    token = "..."
    executor = "virtualbox"
    cache_dir = "/home/lz/cache"




    # Create runner user

  4. lattice0 revised this gist Aug 7, 2022. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -30,6 +30,7 @@ sudo docker exec -it gitlab grep 'Password:' /etc/gitlab/initial_root_password
    # Run `[System.Security.Principal.WindowsIdentity]::GetCurrent().Name` on windows to get the ssh machine machine/username and put into the registered instance (is it really needed? I dont think so)
    # Do as admin:
    reg add HKLM\SOFTWARE\OpenSSH /v DefaultShell /d C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe
    # Install https://git-for-windows.github.io/ with the bash option so bash is available on power shell (IMPORTANT!)
    # Register a runner instance (get the instance token on the panel and substitute below, ALSO edit the URL)

    # For registering a docker instance (don't do this for virtual box vms)
  5. lattice0 revised this gist Aug 7, 2022. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -27,7 +27,9 @@ sudo docker exec -it gitlab grep 'Password:' /etc/gitlab/initial_root_password
    # Install Ubuntu on virtualbox, and remove /home/$USER/.bash_logout file
    # Install Windows on virtualbox, and follow https://docs.gitlab.com/runner/executors/virtualbox.html#checklist-for-windows-vms
    # Do https://superuser.com/a/1606548 on windows
    # Run `[System.Security.Principal.WindowsIdentity]::GetCurrent().Name` on windows to get the ssh machine machine/username and put into the registered instance
    # Run `[System.Security.Principal.WindowsIdentity]::GetCurrent().Name` on windows to get the ssh machine machine/username and put into the registered instance (is it really needed? I dont think so)
    # Do as admin:
    reg add HKLM\SOFTWARE\OpenSSH /v DefaultShell /d C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe
    # Register a runner instance (get the instance token on the panel and substitute below, ALSO edit the URL)

    # For registering a docker instance (don't do this for virtual box vms)
  6. lattice0 revised this gist Aug 6, 2022. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -26,7 +26,8 @@ sudo docker exec -it gitlab grep 'Password:' /etc/gitlab/initial_root_password
    # Install virtualbox
    # Install Ubuntu on virtualbox, and remove /home/$USER/.bash_logout file
    # Install Windows on virtualbox, and follow https://docs.gitlab.com/runner/executors/virtualbox.html#checklist-for-windows-vms

    # Do https://superuser.com/a/1606548 on windows
    # Run `[System.Security.Principal.WindowsIdentity]::GetCurrent().Name` on windows to get the ssh machine machine/username and put into the registered instance
    # Register a runner instance (get the instance token on the panel and substitute below, ALSO edit the URL)

    # For registering a docker instance (don't do this for virtual box vms)
  7. lattice0 created this gist Aug 5, 2022.
    81 changes: 81 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,81 @@
    # Install gitlab dockerized

    export GITLAB_HOME=/srv/gitlab

    sudo docker run --detach \
    --hostname gitlab.example.com \
    --publish 443:443 --publish 80:80 --publish 23:22 \
    --name gitlab \
    --restart always \
    --volume $GITLAB_HOME/config:/etc/gitlab \
    --volume $GITLAB_HOME/logs:/var/log/gitlab \
    --volume $GITLAB_HOME/data:/var/opt/gitlab \
    --shm-size 256m \
    gitlab/gitlab-ee:latest

    # Takes a long time, lookup with

    sudo docker logs -f gitlab

    # When it looks ready, do

    sudo docker exec -it gitlab grep 'Password:' /etc/gitlab/initial_root_password

    # to get the admin password so you can approve the new account. Do the account as your github username/password preferably

    # Install virtualbox
    # Install Ubuntu on virtualbox, and remove /home/$USER/.bash_logout file
    # Install Windows on virtualbox, and follow https://docs.gitlab.com/runner/executors/virtualbox.html#checklist-for-windows-vms

    # Register a runner instance (get the instance token on the panel and substitute below, ALSO edit the URL)

    # For registering a docker instance (don't do this for virtual box vms)
    docker run --rm -v /srv/gitlab-runner/config:/etc/gitlab-runner gitlab/gitlab-runner register \
    --non-interactive \
    --executor "docker" \
    --docker-image alpine:latest \
    --url "http://192.168.1.11" \
    --registration-token "PROJECT_REGISTRATION_TOKEN" \
    --description "docker-runner" \
    --maintenance-note "Free-form maintainer notes about this runner" \
    --tag-list "docker,aws" \
    --run-untagged="true" \
    --locked="false" \
    --access-level="not_protected"

    # I think it's better to install the runner without docker, cause the docker one cannot find virtualbox
    curl -LJO https://gitlab-runner-downloads.s3.amazonaws.com/latest/deb/gitlab-runner_amd64.deb
    sudo apt install -y ./gitlab-runner_amd64.deb

    # For registering a virtualbox instance interatively with docker (does not work after)
    docker run --rm -it -v /srv/gitlab-runner/config:/etc/gitlab-runner gitlab/gitlab-runner register

    # For registering a virtualbox runner without docker

    gitlab-runner register

    # Add the `disable_strict_host_key_checking = true` line to `.gitlab-runner/config.toml` like this:

    concurrent = 1
    check_interval = 0

    [session_server]
    session_timeout = 1800

    [runners.ssh]
    user = "lz"
    password = ""
    disable_strict_host_key_checking = true


    # Create runner user

    useradd gitlab-runner

    # Add the runner user to docker

    sudo usermod -aG docker gitlab-runner

    # Verify that it works (that is, the runner can access docker)

    sudo -u gitlab-runner -H docker info