Skip to content

Instantly share code, notes, and snippets.

View samdoran's full-sized avatar

Sam Doran samdoran

View GitHub Profile
@samdoran
samdoran / diff.patch
Last active April 7, 2023 21:41
Refactoring `get_months_in_date_range`
diff --git koku/api/test_utils.py koku/api/test_utils.py
index 960f4653..daf3c376 100644
--- koku/api/test_utils.py
+++ koku/api/test_utils.py
@@ -290,12 +290,10 @@ class GetMonthsInDateRangeTest(unittest.TestCase):
self.early_start_date = datetime.datetime(2022, 4, 3, tzinfo=pytz.UTC)
self.early_end_date = datetime.datetime(2022, 4, 12, tzinfo=pytz.UTC)
- @patch("api.utils.DateAccessor.today")
@patch("api.utils.DateHelper.today", new_callable=PropertyMock)
@samdoran
samdoran / switch-to-new-coverage-uploader.py
Created November 10, 2021 22:48
Modify a collection to use the new coverage uploader
#!/usr/bin/env python
# Modify a collection to use the new coverage uploader
import argparse
import pathlib
import shutil
import sys
import urllib.request
@samdoran
samdoran / aerohive.md
Last active April 19, 2024 22:14
Configuring Aerohive access points using the CLI

Aerohive

Initial setup

  1. Reset to factory defaults

     reset config bootstrap
     reset config
    

    The username is admin and the password is aerohive or Aerohive1.

@samdoran
samdoran / sshpass.rb
Created September 3, 2021 23:06
Homebrew sshpass formula
require 'formula'
class Sshpass < Formula
url 'http://sourceforge.net/projects/sshpass/files/sshpass/1.06/sshpass-1.06.tar.gz'
homepage 'http://sourceforge.net/projects/sshpass'
sha256 'c6324fcee608b99a58f9870157dfa754837f8c48be3df0f5e2f3accf145dee60'
def install
system "./configure", "--disable-debug", "--disable-dependency-tracking",
"--prefix=#{prefix}"
@samdoran
samdoran / mask.yml
Created October 30, 2020 17:11
systemd mask tests
tasks:
- name: Install chrony
dnf:
name: chrony
state: present
- name: Start, enable, and unmask
systemd:
name: chronyd
state: started
@samdoran
samdoran / test_date_time.py
Last active December 22, 2021 23:59
date_time unit tests
# -*- coding: utf-8 -*-
# Copyright (c) 2020 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
__metaclass__ = type
import pytest
import datetime
@samdoran
samdoran / systemd_default.py
Last active December 22, 2021 23:59
Ansible module to set systemd default target
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright (c) 2020 Sam Doran
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
__metaclass__ = type
DOCUMENTATION = """
@samdoran
samdoran / generate-inventory.py
Created October 31, 2019 15:28
Generate an Ansible inventory with a lot of hosts
#!/usr/bin/env python
import argparse
import os
import sys
import yaml
parser = argparse.ArgumentParser()
parser.add_argument('--number', '-n', default=100)
parser.add_argument('--name', '-f', default='hosts.yml')
@samdoran
samdoran / anisble-py38-st
Created October 16, 2019 16:54
Python 3.8 stack trace
Traceback (most recent call last):
File "/Users/sdoran/Source/ansible/bin/ansible-playbook", line 110, in <module>
exit_code = cli.run()
File "/Users/sdoran/Source/ansible/lib/ansible/cli/playbook.py", line 123, in run
results = pbex.run()
File "/Users/sdoran/Source/ansible/lib/ansible/executor/playbook_executor.py", line 169, in run
result = self._tqm.run(play=play)
File "/Users/sdoran/Source/ansible/lib/ansible/executor/task_queue_manager.py", line 249, in run
play_return = strategy.run(iterator, play_context)
@samdoran
samdoran / merge-pr.py
Created October 14, 2019 21:16
Merge GitHub PRs when the web UI is being dumb
#!/usr/bin/env python
import argparse
import re
import os
from github3 import GitHub
parser = argparse.ArgumentParser()
parser.add_argument('prs', nargs='+')