Skip to content

Instantly share code, notes, and snippets.

View gustavomcarmo's full-sized avatar

Gustavo Muniz do Carmo gustavomcarmo

View GitHub Profile
@gustavomcarmo
gustavomcarmo / bamboo-tag-setting.sh
Created June 27, 2018 13:48
Script to set the TAG value for posterior using in Bamboo job. Assumes the TAG is not latest if follows the semantic versioning, starting with v.
#!/bin/bash
rx='^v([0-9]+\.){0,2}(\*|[0-9]+)$'
if [[ ${bamboo.planRepository.1.revision} =~ $rx ]]; then
TAG=${bamboo.planRepository.1.revision}
else
TAG=latest
fi
echo TAG=$TAG > properties.txt
cat properties.txt
@gustavomcarmo
gustavomcarmo / SeleniumUtils.java
Created July 3, 2018 08:59
Simple Selenium utilitary Java class with a method for waiting a DOM element to be interactable and a method to click an element through Javascript.
package br.com.esign.selenium.utils;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
/**
* Selenium utilitary class
language: java
sudo: required
install: true
services:
- docker
addons:
sonarcloud:
organization: "gustavomcarmo-github"
@gustavomcarmo
gustavomcarmo / playbook-docker-compose-moodle.yml
Created July 6, 2018 14:01
Just an example of Ansible playbook that runs docker-compose and then waits the MySQL container until it becomes ready. Tested on Ubuntu 18.04 LTS (Bionic Beaver).
---
- hosts: moodle
gather_facts: no
become: yes
tasks:
- name: Install required packages
apt:
name: "{{item}}"
update_cache: yes
@gustavomcarmo
gustavomcarmo / configPhpMaxSize.sh
Created July 18, 2018 09:19
Shell script to define the post_max_size and the upload_max_filesize values in the php.ini file.
#!/bin/bash
if [ $# -ne 1 ]; then
echo "One parameter expected:"
echo "- the new size limit (in Mb)"
exit 1
fi
SIZE_IN_MB=$1
if [[ ! $SIZE_IN_MB =~ ^[0-9]+$ || $SIZE_IN_MB -eq 0 ]]; then
@gustavomcarmo
gustavomcarmo / find-latest-ubuntu-bionic-ami.yml
Created December 11, 2018 19:26
Ansible playbook to find the latest Ubuntu 18.04 LTS (bionic) AMI in AWS.
---
- hosts: localhost
gather_facts: no
vars:
aws_region: "eu-west-2"
tasks:
- name: Find Ubuntu Server 18.04 LTS AMIs
ec2_ami_facts:
region: '{{ aws_region }}'
owners: 099720109477
@gustavomcarmo
gustavomcarmo / docker-compose.yml
Last active November 6, 2019 11:56
NGINX + WordPress + MySQL Docker Compose
version: '3'
services:
mysql:
image: mariadb:10.3.12
container_name: mysql
restart: always
volumes:
- mysql_data:/var/lib/mysql
environment:
@gustavomcarmo
gustavomcarmo / test_ldap_entry.sh
Last active September 29, 2020 20:27
LDAP Ansible modules integration tests
#!/bin/bash
docker run --name openldap -d -p 389:389 osixia/openldap:1.2.1
if [ $? -ne 0 ]; then
echo "Error on running the OpenLDAP Docker image."
exit 1
fi
until ldapsearch -x -b dc=example,dc=org -D cn=admin,dc=example,dc=org -w admin | grep "dn: dc=example,dc=org"
do
@gustavomcarmo
gustavomcarmo / Dockerfile
Created July 25, 2018 07:59
Example of Ansible playbook for building a custom Jenkins Docker image and running it in a remote host.
FROM jenkins/jenkins:lts
LABEL maintainer "Gustavo Muniz do Carmo <gustavo@esign.com.br>"
ENV JAVA_OPTS="-Djenkins.install.runSetupWizard=false"
COPY config-maven.groovy /usr/share/jenkins/ref/init.groovy.d/
COPY config-sonarqube.groovy /usr/share/jenkins/ref/init.groovy.d/
COPY harden-jenkins.groovy /usr/share/jenkins/ref/init.groovy.d/
COPY default-user.groovy /usr/share/jenkins/ref/init.groovy.d/
@gustavomcarmo
gustavomcarmo / jenkins-backup.py
Created July 20, 2022 15:44
Jenkins backup by exporting jobs definitions to XML files.
#!/usr/bin/python3
from datetime import datetime
import logging
import os
import requests
def get_params():
if 'JENKINS_URL' not in os.environ or 'JENKINS_ADMIN_USERNAME' not in os.environ or 'JENKINS_ADMIN_PASSWORD' not in os.environ: