Skip to content

Instantly share code, notes, and snippets.

View radimih's full-sized avatar

Radimir Mikhailov radimih

  • IT2G
  • Russia, Kemerovo
View GitHub Profile
@radimih
radimih / .gitlab-ci.yml
Created November 13, 2019 14:19
GitLab CI/CD: job for testing infrastructure (GitLab >= 12.3)
# Добавить в пайплайн задание с ручным запуском для тестирование инфраструктуры
# если изменился файл .gitlab-ci.yml или название ветки начинается с infrastructure
test:infrastructure:
stage: test
rules:
- changes:
- .gitlab-ci.yml
when: manual
- if: '$CI_COMMIT_REF_NAME =~ /^infrastructure\/.*$/i'
when: manual
@radimih
radimih / get_host_address.sh
Created November 23, 2019 13:54
Ansible: get address host from Ansible inventory from bash-script
# Получить адрес хоста по его имени в Ansible inventory
host_address=`ansible --inventory ansible/inventories/hosts.yml \
--module-name debug --args msg="{{ hostvars['host-name'].ansible_host }}" \
--one-line localhost | sed -E 's/.+"msg":\s"(.+)".+/\1/'`
@radimih
radimih / Jenkinsfile
Last active March 2, 2020 10:57
Общие параметры и функции для Jenkins pipeline-файлов
def commonModule
pipeline {
agent { label 'runner-1' }
stages {
stage('Preparation') {
steps {
script {
commonModule = load 'Jenkinsfile.common'
}
@radimih
radimih / README.md
Last active April 2, 2026 11:00
GitLab CI/CD: запуск GitLab Runner через Docker

Из коробки может быть запущен только один экземпляр GitLab Runner. Это можно обойти с помощью Docker. Но зачем? :)

Один GitLab Runner может обслуживать неограниченное количество executor'ов.

Установка

Запуск GitLab Runner

@radimih
radimih / README.md
Last active October 13, 2020 11:05
Postgres: transfer db from one to another host

Transfer global objects (roles & tablespaces)

1: another host (destination):

$ nc -l {port} | [docker exec -i {docker_container}] psql -U postgres

2: one host (source):

@radimih
radimih / README.md
Last active March 10, 2021 11:04
Выпуск самоподписанного SSL-сертификата

Выпуск самоподписанного сертификата

Генерируем сертификат для {FQDN}:

$ cd /etc/nginx/ssl
$ ./gen_cert.sh
$ cd ..
$ vim nginx.conf
server { ... /etc/nginx/ssl/{FQDN}.{crt,key}
@radimih
radimih / main.yml
Created November 27, 2020 09:14
Ansible: stop systemd service if exists
- name: Disable and stoping service if exists
systemd:
service: "{ service name }"
enabled: no
state: stopped
register: result_systemd_stop
failed_when: "result_systemd_stop is failed and 'Could not find the requested service' not in result_systemd_stop.msg"
@radimih
radimih / .dockerignore
Created June 10, 2021 09:28
Dockerfile for Python project
# Исключить все файлы и каталоги
**
# ... кроме следующих:
!Pipfile
!Pipfile.lock
!main.py
@radimih
radimih / README.md
Last active November 19, 2021 04:17
Jinja2 block tags indentation

Jinja2 block tags indentation

---
- hosts: 127.0.0.1
  connection: local
  gather_facts: false
  tasks:
    - name: test indent
 vars:
@radimih
radimih / example.sh
Created March 10, 2022 06:32
Check git repository updates
cd path-to-git-repository
if [ `git log --pretty=%H ...refs/heads/master^` == `git ls-remote origin -h refs/heads/master | cut -f1` ]; then
exit 1;
fi
git pull