Skip to content

Instantly share code, notes, and snippets.

View noonedeadpunk's full-sized avatar

Dmitriy Rabotyagov noonedeadpunk

View GitHub Profile
@noonedeadpunk
noonedeadpunk / README.rst
Last active August 6, 2020 13:47
Mattermost upgrade

In order to use that script, there are some pre-requirements:

1 You're supposed to move content of mattermosts' special directories (config, logs, plugins, client/plugins, and data) to $mattermost_special_dir

2 You should make /opt/mattermost to be a symlink to the real mattermost directory - /opt/mattermost-XX.XX.X/mattermost, where XX.XX.X is current MM version

3 For MM upgrade just run ./upgrade_mattermost.sh YY.YY.Y, where YY.YY.Y is new MM version to be run.

---
- hosts: compute_hosts
gather_facts: true
vars:
# We leave 1 full CPU as a spare one for hypervisor
cpu_spare: "{{ ansible_processor_threads_per_core }}"
cpu_quota: "{{ ansible_processor_vcpus * 100 - cpu_spare * 100 }}%"
tasks:
- name: Update machine.slice
blockinfile:
@noonedeadpunk
noonedeadpunk / current_overcommit_from_nova.py
Last active September 28, 2022 15:26
Get data about current overcommit per hypervisor from OpenStack
#!/usr/bin/python3
import os
from openstack import connect
from pprint import pprint
def main():
conn = connect()
allocation_ratios = {
hv.name: {
"CPU": round(hv.vcpus_used / hv.vcpus, 2),
@noonedeadpunk
noonedeadpunk / timedelta.yml
Last active April 20, 2023 11:23
Calculate a difference in time from current one using plain ansible
- hosts: localhost
tasks:
- name:
vars:
# Should be in format supported by to_time_unit filer:
# https://docs.ansible.com/ansible/latest/collections/community/general/docsite/filter_guide_working_with_times.html
date_difference: "6month"
# Should be in format of python strftime
# https://docs.python.org/3/library/datetime.html#strftime-and-strptime-format-codes
result_format: '%Y-%m-%d %H:%M'