first commit

This commit is contained in:
Neil Borromeo 2022-05-30 17:37:50 +08:00
commit 2660f55733
11 changed files with 248 additions and 0 deletions

21
LICENSE Normal file
View file

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2022 fortisitpl
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

1
README.md Normal file
View file

@ -0,0 +1 @@
# exercices

26
azure-pipelines.yml Normal file
View file

@ -0,0 +1,26 @@
# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml
trigger:
- master
pool:
vmImage: ubuntu-latest
jobs:
- template: job_template.yml
- job: Return
dependsOn: Set
variables:
modules: $[ dependencies.Set.outputs['setVars.MODULES'] ]
modules2: $[ dependencies.Set.outputs['setVars.MODULES2'] ]
steps:
- bash: |
modules=($(modules))
for module in ${modules[@]};do
echo "MODULE: $module"
done
displayName: 'Print variable'

16
job_template.yml Normal file
View file

@ -0,0 +1,16 @@
jobs:
- job: Set
steps:
- script: |
MODULES=("temporar" "tester")
echo "Modules: $MODULES"
echo "##vso[task.setvariable variable=MODULES;isoutput=true]${MODULES[@]}"
echo "##vso[task.setvariable variable=allModules]${MODULES[@]}"
displayName: 'Run a multi-line script'
name: setVars
- script: |
modules=($(allModules))
echo ${modules[@]}
for module in ${modules[@]};do
echo "Module impacted: $module"
done

View file

@ -0,0 +1 @@
# Place for azure devops pipelines

View file

@ -0,0 +1,35 @@
trigger:
- main
resources:
- repo: self
variables:
# Container registry service connection established during pipeline creation
dockerRegistryServiceConnection: 'da808316-c62a-445b-ae0c-3ad87fd75a60'
imageRepository: 'javadocker'
containerRegistry: 'taskjava.azurecr.io'
dockerfilePath: '$(Build.SourcesDirectory)/app/Dockerfile'
tag: '$(Build.BuildId)'
# Agent VM image name
vmImageName: 'ubuntu-latest'
stages:
- stage: Build
displayName: Build and push stage
jobs:
- job: Build
displayName: Build
pool:
vmImage: $(vmImageName)
steps:
- task: Docker@2
displayName: Build and push an image to container registry
inputs:
command: buildAndPush
repository: $(imageRepository)
dockerfile: $(dockerfilePath)
containerRegistry: $(dockerRegistryServiceConnection)
tags: |
$(tag)

View file

@ -0,0 +1,19 @@
trigger:
- main
pool:
vmImage: ubuntu-latest
steps:
- task: Gradle@2
inputs:
workingDirectory: ''
gradleWrapperFile: 'gradlew'
gradleOptions: '-Xmx3072m'
javaHomeOption: 'JDKVersion'
jdkVersionOption: '1.8'
jdkArchitectureOption: 'x64'
publishJUnitResults: true
testResultsFiles: '**/TEST-*.xml'
tasks: 'build'

20
task_template.yml Normal file
View file

@ -0,0 +1,20 @@
parameters:
- name: modules
steps:
#- ${{ each module in parameters.modules }}
#- task: Docker@2
# inputs:
# repository: ${{ parameters.image_name }}
# command: "buildAndPush"
# Dockerfile: ${{ module }}/Dockerfile
# buildContext: ${{ parameters.image_context }}
# arguments: ${{ parameters.arguments }}
# displayName: 'Docker build and push'
# condition: and(succeeded(), eq(variables['SHOULD_PUSH'], true))
- bash: |
modules=(${{ parameters.modules }})
for module in $modules;do
echo "Module impacted: $module"
done

View file

@ -0,0 +1 @@
# Place for terraform code for Azure

84
terraform/azure/main.tf Normal file
View file

@ -0,0 +1,84 @@
terraform {
required_version = ">=0.12"
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "~>2.0"
}
}
}
resource "azurerm_resource_group" "resource_gp" {
name = "terraRG"
location = "southeastasia"
tags = {
Owner = "Elvi"
}
}
variable "prefix" {
default = "lv"
}
resource "azurerm_virtual_network" "main" {
name = "${var.prefix}-network"
address_space = ["10.0.0.0/16"]
location = azurerm_resource_group.resource_gp.location
resource_group_name = azurerm_resource_group.resource_gp.name
}
resource "azurerm_subnet" "internal" {
name = "internal"
resource_group_name = azurerm_resource_group.resource_gp.name
virtual_network_name = azurerm_virtual_network.main.name
address_prefixes = ["10.0.2.0/24"]
}
resource "azurerm_network_interface" "main" {
name = "${var.prefix}-nic"
location = azurerm_resource_group.resource_gp.location
resource_group_name = azurerm_resource_group.resource_gp.name
ip_configuration {
name = "testconfiguration1"
subnet_id = azurerm_subnet.internal.id
private_ip_address_allocation = "Dynamic"
}
}
resource "azurerm_virtual_machine" "main" {
name = "${var.prefix}-vm"
location = azurerm_resource_group.resource_gp.location
resource_group_name = azurerm_resource_group.resource_gp.name
network_interface_ids = [azurerm_network_interface.main.id]
vm_size = "Standard_DS1_v2"
storage_image_reference {
publisher = "Canonical"
offer = "UbuntuServer"
sku = "16.04-LTS"
version = "latest"
}
storage_os_disk {
name = "testdisk01"
caching = "ReadWrite"
create_option = "FromImage"
managed_disk_type = "Standard_LRS"
}
os_profile {
computer_name = "test-pc"
admin_username = "testadmin"
admin_password = "Password1234!"
}
os_profile_linux_config {
disable_password_authentication = false
}
tags = {
Owner = "Elvi"
}
}

View file

@ -0,0 +1,24 @@
provider "azurerm"{
subscription_id = var.subscription_id
client_id = var.client_id
client_secret = var.client_secret
tenant_id = var.tenant_id
features {}
}
variable "subscription_id"{
description = "Enter Subscription ID "
}
variable "client_id"{
description = "Enter Client ID "
}
variable "client_secret"{
description = "Enter Client Secret "
}
variable "tenant_id"{
description = "Enter Tenant ID"
}