Felipe Fonseca Rocha
Curioso por natureza e grande apreciador de novos conhecimentos, independente da disciplina!
Introdução
Ciclo de Vida
Asset: Server | Configuration Item: Server |
---|---|
Make Model CPU RAM OS Etc. |
Technical: Technical attributes that are similar to Asset attributes Ownership: Responsible Person Purchase Date Warranty Info Location Relationship: Details about how this CI contributes to the delivery of a service which ultimately brings value to the business |
Escalabilidade, Agilidade e consistência
O caminho para
Pré DevOps
Era DevOps
Ferramentas vs Plataformas
Paralelo Com Engenharia
Que dirá sistemas, redes...
Bash, CMD, PWSH etc
CI / CD
Kubernetes (tudo)
docker (docker compose)
IaC (AWS)
Linguagem de serialização de dados
Engenheiro de Yaml
--- # Comecei um documento yaml
chave: valor
estrutura:
doisEspacos:
- lista
- item
- objeto:
depende:
doObjeto: vai se estruturar #string são validas
# Comentarios entre linhas
estrura:
- pode: variar
- numero: 1
- datas: 2020-12-12
--- # proximo documento
versao: 5
.ponteiro: &ponteiro
conteudo: repetido
recurso: *ponteiro
---
invoice: 34843
date : 2001-01-23
bill-to: &id001
given : Chris
family : Dumars
address:
lines: |
458 Walkman Dr.
Suite #292
city : Royal Oak
state : MI
postal : 48046
ship-to: *id001
product:
- sku : BL394D
quantity : 4
description : Basketball
price : 450.00
- sku : BL4438H
quantity : 1
description : Super Hoop
price : 2392.00
tax : 251.42
total: 4443.52
comments:
Late afternoon is best.
Backup contact is Nancy
Billsmer @ 338-4338.
Desde 2012...
Modulos & Utilitários
Modulos & Utilitários
Plugins
Inventário
---
[webservers]
www1.example.com
www2.example.com
[dbservers]
db0.example.com
db1.example.com
[casa]
1x7.7x.11x.42
[develop:children]
casa
[develop:vars]
ansible_connection=ssh
ansible_ssh_private_key_file=/home/felipe/.ssh/id_rsa
ansible_user=felipe
Playbook
---
- hosts: webservers
serial: 5 # update 5 machines at a time
roles:
- common
- webapp
- hosts: dbservers
roles:
- common
- content
---
- hosts: casa
become: yes
become_method: sudo
remote_user: "{{ remote_user }}"
gather_facts: no
pre_tasks:
- name: Atualizando Repository
raw: apt-get update -y && apt-get full-upgrade -y
- name: Distribuicao linux
shell: lsb_release -cs
register: distribuicao_linux
- name: Codename Distribuição
shell: lsb_release -is
register: code_name_linux
tasks:
- name: Instalando o Apache and common files
apt: "{{ packages }}"
vars:
packages:
- apache2
- python3
- python3-pip
- apt-transport-https
- ca-certificates
- curl
- gnupg-agent
- software-properties-common
- name: Adicionando Docker GPG key
apt_key: url=https://download.docker.com/linux/ubuntu/gpg
- name: Adicionando Docker APT repository
apt_repository:
repo: deb [arch=amd64] https://download.docker.com/linux/ubuntu {{ distribuicao_linux.stdout |lower }} {{ code_name_linux.stdout }} stable
- name: Instalando Docker
apt: "{{ packages}}"
vars:
packages:
- docker-ce
- docker-ce-cli
- containerd.io
variables:
DOCKER_TLS_CERTDIR: ''
DOCKER_DRIVER: overlay2
cache:
paths:
- .m2/repository
stages:
- test
- build
- deploy
.set_configs: &set_configs
# Setup tools
- apk add --no-cache maven curl jq
test:
stage: test
image: openjdk:8-jdk-alpine
before_script:
- apk add --no-cache maven
script: |
mvn clean package -Dmaven.test.skip=true
mvn test
build:
stage: build
image: openjdk:8-jdk-alpine
dependencies:
- test
artifacts:
paths:
- app.jar
before_script: *set_configs
script: |
# Build jar with param
mvn package \
-Dmaven.test.skip=true
cp target/*.jar app.jar
only:
- master
deploy:
stage: deploy
image: docker:19.03.0
services:
- name: docker:19.03.0-dind
dependencies:
- build
before_script: *set_configs
script:
- docker info
- docker --version
- docker build --build-arg JAR_FILE=app.jar -t "felipefrocha89/springboot-api" .
- docker tag "felipefrocha89/springboot-api:latest" "felipefrocha89/springboot-api:${CI_COMMIT_SHA:0:8}"
after_script:
- docker login -u felipefrocha89 -p $PASSWORD
- docker push "felipefrocha89/springboot-api:${CI_COMMIT_SHA:0:8}"
- docker push "felipefrocha89/springboot-api:latest"
only:
- master
www.gitlab.com
---
version: 2
jobs:
test:
docker:
- image: circleci/openjdk:8u252-jdk
working_directory: ~/sample-springboot-api
steps:
- checkout
- restore_cache:
keys:
- sample-springboot-api-{{ checksum "pom.xml" }}
- run:
name: Dependency check
command: mvn dependency:go-offline
- save_cache:
paths:
- ~/.m2
key: sample-springboot-api-{{ checksum "pom.xml" }}
# package into a jar
- run:
name: Test
command: |
mvn clean package -Dmaven.test.skip=true
mvn test
build_deploy:
docker:
- image: circleci/openjdk:8u252-jdk
working_directory: ~/sample-springboot-api
steps:
# git pull
- checkout
- run:
name: Login to DockerHub
command: echo $DOCKER_PASS | docker login -u $DOCKER_USER --password-stdin
# Download and cache dependencies
- restore_cache:
keys:
- sample-springboot-api-{{ checksum "pom.xml" }}
- run: mvn dependency:go-offline
- save_cache:
paths:
- ~/.m2
key: sample-springboot-api-{{ checksum "pom.xml" }}
# package into a jar
- run:
name: Build Skiping Test
command: mvn clean package -Dmaven.test.skip=true
# build and push docker image to docker hub
- run:
name: Maven Plugin Docker Image
command: mvn clean compile jib:build -Dimage=felipefrocha89/springboot-api:$CIRCLE_BUILD_NUM
# store raw contents of src code
- store_artifacts:
path: target/classes
destination: sample-springboot-api
workflows:
version: 2
test:
jobs:
- test:
filters:
branches:
ignore:
- master
build_deploy:
jobs:
- test
- build_deploy:
filters:
branches:
ignore:
- /feature.*/
requires:
- test
www.circleci.com
https://microsoft.github.io/PartsUnlimitedMRP/pandp/200.1x-PandP-PythonCI.html
https://circleci.com/blog/tag/tutorials/
https://docs.gitlab.com/ee/ci/
https://martinfowler.com/articles/continuousIntegration.html
https://martinfowler.com/bliki/ContinuousDelivery.html
https://medium.com/faun/types-of-application-deployment-36772c0adf46
https://opensource.com/article/17/5/colorful-deployments
https://www.thoughtworks.com/continuous-integration
https://www.thoughtworks.com/continuous-delivery
Links
By Felipe Fonseca Rocha
Este breve deck é sobre #Ansible, passando apenas os conceitos básicos e fluxo de utilização. O foco apenas habilitar os interessados a começarem a automatizar configurações de servidores e imagens.
Curioso por natureza e grande apreciador de novos conhecimentos, independente da disciplina!