Skip to content

Instantly share code, notes, and snippets.

Avatar

Dmitriy Rabotyagov noonedeadpunk

View GitHub Profile
View set_libvirt_cpu_quota.yml
---
- 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 / README.rst
Last active Aug 6, 2020
Mattermost upgrade
View README.rst

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.

@noonedeadpunk
noonedeadpunk / diff
Created Jun 24, 2020
SPICE console ctrl+alt+del button
View diff
/usr/share/spice-html5/spice_auto.html:
<div id="login">
<span class="logo">SPICE</span>
+ <div class="spice-send-ctrl-alt-del">
+ <button type="button" onclick="sendCtrlAltDel()">
+ Send Ctrl-Alt-Delete
+ </button>
+ </div>
</div>
@noonedeadpunk
noonedeadpunk / add_1password_server.yml
Created May 21, 2020
1Password add server and ipmi playbook
View add_1password_server.yml
- name: Reset password
hosts: "{{ host }}"
vars:
ipmi_password: "{{ lookup('password', '/tmp/' ~ inventory_hostname ~ '_ipmipassword chars=ascii_letters,digits length=16') }}"
system_password: "{{ lookup('password', '/tmp/' ~ inventory_hostname ~ '_rootpassword chars=ascii_letters,digits,-,_,! length=20') }}"
tasks:
- name: install ipmitool
package:
name: ipmitool
state: present
@noonedeadpunk
noonedeadpunk / ipa-client-install.yml
Last active May 5, 2020
Add hosts to ipa server
View ipa-client-install.yml
---
- name: Install and configure ipa-client
hosts: "{{ hosts }}"
tasks:
- name: Install ipa-client package
package:
name: "{{ (ansible_os_family == 'Debian') | ternary('freeipa-client', 'ipa-client') }}"
state: installed
register: ipa_install
- name: Run configuration command
View sync-chorny.yml
---
- name: Sync clock with chrony
hosts: all
tasks:
- name: disable ntp
service:
name: ntp
state: stopped
enabled: false
failed_when: false
View create_user.yml
---
- name: Create users
hosts: all
vars:
group: mygroup
user: myuser
keys_path: ./ssh_keys
tasks:
- name: Create group
group:
@noonedeadpunk
noonedeadpunk / gist:4a22b2dcc3b22fcc295445ed18c66247
Last active Dec 27, 2019
Drop rabbitmq queues without consumers
View gist:4a22b2dcc3b22fcc295445ed18c66247
### Classis FOR ###
vhost="/"; for queue in `rabbitmqctl list_queues name consumers -p $vhost --formatter csv`; do name=`echo $queue | cut -d "," -f 1 | tr -d '"'`; consumers=`echo $queue | cut -d "," -f 2 | tr -d '"'`; if [[ "$consumers" == "0" ]]; then rabbitmqctl delete_queue $name -p $vhost ; fi; done
### Faster XARGS ###
vhost="/"; rabbitmqctl list_queues name consumers -p $vhost --formatter csv | xargs -P 20 -I {} env vhost=$vhost bash -c 'name=$(echo {} | cut -d "," -f 1); consumers=$(echo {} | cut -d "," -f 2); if [[ "$consumers" != "0" ]]; then rabbitmqctl delete_queue $name -p $vhost ; fi'
View gist:9a260f23ec78676576f4b19d79a4b679
ROLES_DIR="/etc/ansible/roles/"; pushd $ROLES_DIR; ROLES=`ls -1`; popd; for role in $ROLES; do pushd $ROLES_DIR/$role; git diff; popd; done
@noonedeadpunk
noonedeadpunk / compare_conf.py
Last active Dec 12, 2019
Compare config files with configparser
View compare_conf.py
#!/usr/bin/env python
import configparser
import itertools
import sys
from pprint import pprint
def compare_confs(src, dst):
src_conf = configparser.RawConfigParser()