Git Product home page Git Product logo

gitlab-terraform-demo's Introduction

GitLab Terraform Demo

Some code to create content within a GitLab environment. This will create a public project with a repo and a sample Java app with CI build

Usage

  • Ensure you have a GitLab runner for your environment (not really needed - you can ignore this - you just won't have a pipeline run)

    docker run -d --name gitlab-runner --privileged --network host --restart always \
    -v /srv/gitlab-runner/config:/etc/gitlab-runner -v /var/run/docker.sock:/var/run/docker.sock \
    --hostname 172.17.0.3 gitlab/gitlab-runner:latest
    
    export REG_TOKEN="<Your Runner Registration token>"
    docker run --rm -it --privileged --network host -v /srv/gitlab-runner/config:/etc/gitlab-runner \
    gitlab/gitlab-runner --debug -l debug register --non-interactive  --url "http://localhost" \
    --registration-token "$REG_TOKEN" --executor "docker" --docker-image alpine:latest --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"
    
    # Update the runner to use host network (sigh)
    sudo vi /srv/gitlab-runner/config/config.toml
      # Under [runners.docker]
      network_mode = "host"
    
    # Restart the runner 
    docker ps 
    docker stop gitlab-runner  # Might need the container ID here instead of gitlab-runner
    docker start gitlab-runner
  • Log into an existing GitLab server and create a personal access token. In the upper right click your user icon and click Edit Profile. Then on the left menu click 'Access Tokens'. Create a personal access token with all scopes.

    • MAKE CERTAIN THIS IS CALLED Migration Token
    • Direct by URL would be https://YourGitlab.example.com/-/profile/personal_access_tokens
  • Clone this repo

  • Create a var file like env.tfvars with your environment details

gitlab_token = "glpat-#############"
gitlab_url   ="http://localhost"
##gitlab_url   = "https://YourGitlab.example.com/api/v4/"
  • Execute Terraform
apt-get update && apt-get -y install terraform
terraform init
terraform apply -var-file=env.tfvars

Note this will run scripts/java_hello_automation.sh to setup and configure the GitLab CLI and populate some repo content

  • Once all done, cleanup:
terraform apply -destroy -var-file=env.tfvars

gitlab-terraform-demo's People

Contributors

jonjozwiak avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.