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 / playbook-nexus-maven-settings.yml
Created June 29, 2018 07:59
Ansible playbook to setup a Maven environment for a user in a remote host. The user then will use a instance of Nexus for downloading Java artifacts.
---
- hosts: nexus-client-hosts
gather_facts: no
vars_prompt:
- name: "maven_master_password"
prompt: "Maven master password"
private: yes
- name: "nexus_username"
prompt: "Nexus username"
@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 / configure-zabbix.yml
Created July 25, 2018 07:30
Example of Ansible playbook for installing and configuring the Zabbix agent in a host and then creating the host in a Zabbix server.
---
- name: Install the Zabbix agent
yum:
name: http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-agent-3.4.8-1.el7.x86_64.rpm
- name: Configure the Zabbix agent
replace:
path: /etc/zabbix/zabbix_agentd.conf
regexp: '{{item.regexp}}'
replace: '{{item.replace}}'
with_items:
@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 / 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 / docker-volumes-backup.yml
Created September 13, 2018 18:12
Ansible playbook to backup all Docker volumes in a remote host and then upload the backup file to a raw Nexus repository.
---
- hosts: remote
gather_facts: no
tasks:
- name: Make the volumes backup
archive:
path: /var/lib/docker/volumes
dest: volumes.tar.gz
- name: Make the backup available (requires vault-password-file)
uri: