Giter Site home page Giter Site logo

challenge-gitlab's Introduction

challenge-gitlab

this challenge is to automate the installation of gitlab on microsoft auzre (acloudguru azure sandbox) using terraform and ansible

getting started

prerequisites

ensure you have the following prepared and installed on your machine

  1. python
  2. az cli
  3. terraform
  4. ansible
  5. username and password provided by acloudguru azure sandbox (or your own azure account)

running terraform and ansible

a - preparing the code

  1. you can either git clone or download the code as zip file and extract it to a directory on your machine

b - preparing terraform main.tf file

  1. login to azure portal using the username and password generated by acloudgure azure sandbox
  2. copy the generated resource group name in azure portal
  3. open main.tf file and replace the default value of variable "rg" with the copied resource group name
  4. save the main.tf file

c - running terraform main.tf file

  1. open a terminal on your machine and navigate to the code directory
  2. type az logout to logout of any previous az sessions
  3. type az login -u <username> to login to az using the generated username
  4. enter the generated password when prompted
  5. begin the initialization of terraform using terraform init
  6. (optional) plan terraform using terraform plan
  7. apply terraform using terraform apply --auto-approve and wait for it to complete
  8. when completed, resources will be deployed in azure portal and three files (inventory, fqdn, password) will be generated in the working directory for use in ansible

note

while terraform will report the deployment is completed, the resources are still being spun up in the background in azure and will not be ready straight away, thus it is recommended to wait for around 10 mins before proceeding to the next step


d - running ansible main.yml file

  1. ensure you are still in the same directory in the terminal
  2. type ansible-playbook main.yml to start the process
  3. when completed, you should be able to access the gitlab login page using the fqdn (url) generated in the fqdn file

e - terraform destroy and cleaning up

  1. in terminal, type terraform destroy --auto-approve to destroy the resources created and files generated on local machine

further reading

finding the publisher, offer and sku of image

to install gitlab onto a vm, we are required to use the image provided by gitlab

in azure portal, we only need to do a search to find the gitlab image and use it to create the vm. however we are required to provide publisher, offer and sku of the image to automate and create the vm in terraform

there are multiple methods to find the required parameters of the gitlab image (or other images by other publishers)

1. arm template and az powershell

this fantastic article guide you on how to find publisher, offer and sku through arm (azure resource manager) template and az powershell

2. az cli

this az vm image document by microsoft lists the commands to find publisher, offer, sku and more

example instructions for az cli to find the sku of gitlab by first finding the publisher , then offer, and finally sku

  1. ensure you are login to az in terminal using az login -u <username> and enter the password when prompted
  2. type az vm image list-publishers --location eastus > publisher.txt in terminal to output a txt file with a list publishers in eastus
  3. open the publisher txt file and search for gitlab (there may be multiple results) and note down the name value (as of 17 Mar 2022, gitlabinc1586447921813 is the correct publisher for the image we need to use)
  4. type az vm image list-offers --location eastus --publisher gitlabinc1586447921813 > offer.txt in terminal to output a txt file with a list of offers by gitlabinc1586447921813
  5. open the offer txt file and note down the name value (it should be gitlabee)
  6. type az vm image list-skus --location eastus --offer gitlabee --publisher gitlabinc1586447921813 > sku.txt in terminal to output a txt file with a list of skus
  7. open the sku txt file and note down the name value (it should be default)
  8. add the publisher, offer and sku we found above to the terraform file to automate the creation of vm using the gitlab image

work in progress

working in integrating both terraform script and ansible script so the automation is seemless (code is already present in the main.tf file)

currently there is an issue failed to connect to the host via ssh: shared connection to <ip address> closed. if we run ansible playbook right after terraform has deployed the resources

i believe it is due to the vm closing the ssh connection as one of the ansible tasks is to wait and check for bitnami credential

challenge-gitlab's People

Contributors

vysky avatar ytbryan 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.