Skip to content

Instantly share code, notes, and snippets.

file_line { 'enable_agent_forwarding':
path => '/etc/ssh/sshd_config',
line => 'AgentForwarding yes',
match => '^AgentForwarding',
ensure => present,
require => File['/etc/ssh/sshd_config'],
}
---
- name: Add Prefix to Strings
hosts: localhost
gather_facts: no
vars:
my_strings:
- apple
- banana
- orange
[req]
distinguished_name = req_distinguished_name
req_extensions = v3_req
prompt = no
[req_distinguished_name]
countryName = YOUR_COUNTRY_CODE
stateOrProvinceName = YOUR_STATE
localityName = YOUR_CITY
organizationName = YOUR_ORGANIZATION
@stacklikemind
stacklikemind / gist:10d4b09dff0c4357034ca53ef619a8cf
Created August 1, 2023 21:50
Concatenate DNS hostnames from inventory
---
- name: Concatenate DNS hostnames from inventory (excluding a group)
hosts: all
gather_facts: false
tasks:
- name: Filter hosts by excluding a group
set_fact:
dns_hosts: "{{ ansible_play_hosts_all | difference(groups['your_excluded_group']) }}"
---
- name: Define your role
hosts: your_host
vars:
keystore_path: "/path/to/keystore"
truststore_path: "/path/to/truststore"
keystore_password: "your_keystore_password"
truststore_password: "your_truststore_password"
tasks:
import requests
from msal import PublicClientApplication
# define the necessary variables for authentication
CLIENT_ID = 'your_client_id'
AUTHORITY = 'https://login.microsoftonline.com/common'
SCOPE = ['User.ReadBasic.All']
# create a PublicClientApplication object
app = PublicClientApplication(client_id=CLIENT_ID, authority=AUTHORITY)
@stacklikemind
stacklikemind / gist:4a467d6bd1e5cc965df69d39e67c22ef
Created April 26, 2023 12:32
synthetic data creator sample
# Set the date to the current date and time
$date = Get-Date
# Loop through 24 hours
for ($i = 0; $i -lt 24; $i++) {
# Set the date and time for the current iteration
$currentDate = $date.AddHours($i)
# Set the path for the current year, month, day, hour, and minute
# $yearPath = "$($currentDate.Year)"
# encoding: utf-8
require "logstash/filters/base"
require "logstash/namespace"
require "csv"
class LogStash::Filters::UsernameFilter < LogStash::Filters::Base
config_name "usernamefilter"
# The path to the CSV file containing the list of usernames
config :csv_path, :validate => :path, :required => true
import asyncio
import multiprocessing
from aiokafka import AIOKafkaConsumer, TopicPartition
async def consume_partition(partition, bootstrap_servers):
topic = "my-topic"
group_id = "my-group"
consumer = AIOKafkaConsumer(
bootstrap_servers=bootstrap_servers,
group_id=group_id,
import asyncio
from aiokafka import AIOKafkaConsumer
async def consume(partition):
consumer_conf = {
"bootstrap_servers": "localhost:9092",
"group_id": "my-group",
"auto_offset_reset": "earliest"
}