Skip to content

Commit

Permalink
last change
Browse files Browse the repository at this point in the history
  • Loading branch information
b08x committed Jan 2, 2024
1 parent ea1d6cf commit c747241
Show file tree
Hide file tree
Showing 34 changed files with 651 additions and 254 deletions.
17 changes: 17 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Gemfile

source 'https://rubygems.org'

gem 'debug', '1.8.0'
gem 'google-protobuf', '3.25.0'
gem 'io-console', '0.6.0'
gem 'irb', '1.8.3'
gem 'pry'
gem 'pry-doc'
gem 'psych', '5.1.1.1'
gem 'rake'
gem 'rdoc', '6.5.0'
gem 'reline', '0.3.9'
gem 'sorbet-runtime', '0.5.11116'
gem 'stringio', '3.0.8'
gem 'tty-progressbar'
69 changes: 69 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
GEM
remote: https://rubygems.org/
specs:
coderay (1.1.3)
debug (1.8.0)
irb (>= 1.5.0)
reline (>= 0.3.1)
google-protobuf (3.25.0)
google-protobuf (3.25.0-aarch64-linux)
google-protobuf (3.25.0-arm64-darwin)
google-protobuf (3.25.0-x86-linux)
google-protobuf (3.25.0-x86_64-darwin)
google-protobuf (3.25.0-x86_64-linux)
io-console (0.6.0)
irb (1.8.3)
rdoc
reline (>= 0.3.8)
method_source (1.0.0)
pry (0.14.2)
coderay (~> 1.1)
method_source (~> 1.0)
pry-doc (1.4.0)
pry (~> 0.11)
yard (~> 0.9.11)
psych (5.1.1.1)
stringio
rake (13.1.0)
rdoc (6.5.0)
psych (>= 4.0.0)
reline (0.3.9)
io-console (~> 0.5)
sorbet-runtime (0.5.11116)
stringio (3.0.8)
strings-ansi (0.2.0)
tty-cursor (0.7.1)
tty-progressbar (0.18.2)
strings-ansi (~> 0.2)
tty-cursor (~> 0.7)
tty-screen (~> 0.8)
unicode-display_width (>= 1.6, < 3.0)
tty-screen (0.8.2)
unicode-display_width (2.5.0)
yard (0.9.34)

PLATFORMS
aarch64-linux
arm64-darwin
ruby
x86-linux
x86_64-darwin
x86_64-linux

DEPENDENCIES
debug (= 1.8.0)
google-protobuf (= 3.25.0)
io-console (= 0.6.0)
irb (= 1.8.3)
pry
pry-doc
psych (= 5.1.1.1)
rake
rdoc (= 6.5.0)
reline (= 0.3.9)
sorbet-runtime (= 0.5.11116)
stringio (= 3.0.8)
tty-progressbar

BUNDLED WITH
2.5.3
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ An exercise in configuration management. Intended to serve as an IaC framework f

The repository contains Ansible roles, playbooks, and modules to help configure and manage Linux hosts that are part of an audio production workflow.

## directory index
## Directory Index

| Path | Content | |
| :------------------------ | :------------------------------------------ | --- |
Expand Down Expand Up @@ -42,7 +42,7 @@ vars/{{ distro }}/packages.yml - package lists

var/stheme.yml - theme variables

### role variables
### Role Variables

#### defaults/main.yml

Expand All @@ -60,6 +60,13 @@ var/stheme.yml - theme variables

- Role variables allow users to customize the role without modifying the role's default behavior.

### Using Tags

```bash
ansible-playbook -i inventory.ini playbooks/full.yml --tags $TAGS --limit $HOSTNAME
```


# demo

[![asciicast](https://asciinema.org/a/622463.svg)](https://asciinema.org/a/622463)
Expand Down
125 changes: 125 additions & 0 deletions bin/cfgmgv3.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require 'cli/ui'
require 'yaml'
require 'json'
require 'csv'
require 'open4'
require "tty-prompt"


if ENV['ANSIBLE_HOME']
ANSIBLE_HOME = ENV['ANSIBLE_HOME']
else
ANSIBLE_HOME = File.expand_path('..', __dir__)
end

VARS = File.join(ANSIBLE_HOME, 'vars')
PLAYBOOKS = File.join(ANSIBLE_HOME, 'playbooks')
GROUP_VARS = File.join(ANSIBLE_HOME, 'group_vars')
HOST_VARS = File.join(ANSIBLE_HOME, 'host_vars')
ROLES = File.join(ANSIBLE_HOME, 'roles')
INVENTORY = File.join(ANSIBLE_HOME, 'inventory.ini')



class Ansible

attr_accessor :inventory, :playbooks, :group_vars, :host_vars, :tags

def initialize(location)
@playbooks = Dir.children(PLAYBOOKS)
@group_vars = File.join(location, 'group_vars')
@host_vars = File.join(location, 'host_vars')
end

def tags(playbook)
@tags = `ansible-playbook -i #{INVENTORY} #{playbook} --list-tags | awk -F 'TASK TAGS:' '{print $2}'`.chomp.strip.gsub(/\[|\]|,/,'')
end


end

# select playbook


syncopated = Ansible.new(ANSIBLE_HOME)

p syncopated.playbooks

playbook = `gum filter #{Dir.children(PLAYBOOKS).join(' ')}`.chomp.strip
p playbook

tags = syncopated.tags(File.join(PLAYBOOKS, playbook))
p tags

t = `gum filter #{tags} --no-limit`.chomp.split("\n")

p t







CLI::UI::StdoutRouter.enable



CLI::UI::Frame.open('{{*}} {{bold:a}}', color: :green) do
puts "hey fucker, select a playbook"
puts "full playbook selected, retriveing tags"
CLI::UI::Frame.open('{{i}} b', color: :magenta) do
puts "select tags to run..."
CLI::UI::Frame.open('{{?}} c', color: :cyan) do

@distro = CLI::UI.ask('Select Distro', options: %w(AlmaLinux Archlinux))

end

end

CLI::UI::Frame.divider('{{v}} lol')

puts "#{@distro}"

packages = YAML.load_file(File.join(VARS, "#{@distro}", "packages.yml"))

prompt = TTY::Prompt.new

choice = prompt.multi_select("Select packages", packages["packages"]).flatten

t = `gum filter #{choice.join(' ')} --no-limit`.chomp.split("\n")

p t

end


def test(arg)
puts "hey fucker"
end

CLI::UI::Frame.open('{{i}} b', color: :magenta) do

CLI::UI::Prompt.ask('What language/framework do you use?') do |handler|
handler.option('rails') { |selection| test(selection) }
handler.option('go') { |selection| selection }
handler.option('ruby') { |selection| selection }
handler.option('python') { |selection| selection }
end

end

CLI::UI::Progress.progress do |bar|
100.times do
bar.tick
end
end

CLI::UI::SpinGroup.new do |spin_group|
spin_group.add('Title') { |spinner| `ansible-playbook -C -i /home/b08x/Workspace/syncopatedIaC/inventory.ini /home/b08x/Workspace/syncopatedIaC/playbooks/full.yml --limit lapbot --tags desktop` }
spin_group.add('Title 2') { |spinner| sleep 3.0; spinner.update_title('New Title'); sleep 3.0 }
end
37 changes: 37 additions & 0 deletions bin/package_names.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env bash


# Supported filters are:
#
# search
# project name substring to look for
# maintainer
# return projects maintainer by specified person
# category
# return projects with specified category
# inrepo
# return projects present in specified repository
# notinrepo
# return projects absent in specified repository
# repos
# return projects present in specified number of repositories (exact values and open/closed ranges are allowed, e.g. 1, 5-, -5, 2-7
# families
# return projects present in specified number of repository families (for instance, use 1 to get unique projects)
# repos_newest
# return projects which are up to date in specified number of repositories
# families_newest
# return projects which are up to date in specified number of repository families
# newest
# return newest projects only
# outdated
# return outdated projects only
# problematic
# return problematic projects only

# Example: get unique outdated projects not present in FreeBSD maintainer by [email protected]
#
# /api/v1/projects/?notinrepo=freebsd&[email protected]&families=1&outdated=1

curl -s "https://repology.org/api/v1/projects/?inrepo=arcg&search=ambix"|jq

curl -s "https://repology.org/api/v1/project/ambix" | jq
58 changes: 58 additions & 0 deletions bin/something.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/usr/bin/env ruby
require 'cli/ui'
require 'yaml'
require 'json'
require 'csv'
require 'open4'
require "tty-prompt"

INVENTORY = '$ANSIBLE_HOME/hosts'
PLAYBOOK = '$ANSIBLE_HOME/soundbot.yml'

# module Ansible
# module_function
#
# def playbook(*args)
# Soundbot::Command.tty("ansible-playbook -i #{INVENTORY} #{PLAYBOOK} #{args.join(' ')}")
# end
#
# def tags
#
# tags = playbook("--list-tags")
#
# return tags
#
# end
#
# def tasks
#
# tasks = playbook("--list-tasks")
#
# return tasks
# end
#
# def start_at_task(task)
# playbook("--start-at-task=#{task}")
# end
#
# end

#!/usr/bin/env ruby
# send osc messages to sonic-pi for every line printed when running a playbook
# https://stackoverflow.com/a/43208709/10073106

require 'open3'
require 'tty-progressbar'
bar = TTY::ProgressBar.new("importing [:bar] :elapsed :percent", total: 225 )


Dir.chdir(File.join(ENV["HOME"], "Workspace", "syncopatedIaC")) do
Open3.popen3 "ansible-playbook -C -i inventory.ini playbooks/full.yml --limit lapbot" do |stdin, stdout, stderr, thread|
while line = stdout.gets
# puts line
# `oscsend localhost 4560 /test/thing s "#{line}"` if line.include?("TASK")
bar.log("#{line.gsub(/\*/,'')}")
bar.advance if line.include?("TASK")
end
end
end
24 changes: 17 additions & 7 deletions bin/tasks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,30 @@
INVENTORY="${ANSIBLE_HOME}/inventory.ini"
PLAYBOOKS="${ANSIBLE_HOME}/playbooks"

# tags=$(ansible-playbook -i $INVENTORY $PLAYBOOKS/full.yml --list-tags | awk -F 'TASK TAGS:' '{print $2}' | xargs |
# xargs | sd '^\[|\]|,' '')
declare -a tags=$(ansible-playbook -i $INVENTORY $PLAYBOOKS/full.yml --list-tags | awk -F 'TASK TAGS:' '{print $2}' | sd '^\[|\]|,' '')
echo $tags
# | xargs | xargs
#
# gum choose --no-limit ${tags[@]}
declare -a todo=$(gum choose --no-limit ${tags[@]})

# tasks=$(ansible-playbook -i $INVENTORY "${PLAYBOOKS}/full.yml" --list-tasks | awk -F ':' '{print $2}' | awk -F '\t' '{print $1}'| uniq | gum filter --no-limit)
echo ${todo}

tasks=$(ansible-playbook -i $INVENTORY "${PLAYBOOKS}/full.yml" --list-tasks | awk -F ':' '{print $2}' | awk -F '\t' '{print $1}'| uniq)

echo $tasks
exit
# tasks=$(ansible-playbook -i $INVENTORY "${PLAYBOOKS}/full.yml" --list-tasks | awk -F ':' '{print $2}' | awk -F '\t' '{print $1}'| uniq | gum filter --no-limit)

# tasks=$(ansible-playbook -i $INVENTORY "${PLAYBOOKS}/full.yml" --list-tasks | awk -F ':' '{print $2}' | awk -F '\t' '{print $1}'| uniq)
#
# echo $tasks
# exit

# for task in "${tasks[@]}"; do
# ansible-playbook -i $INVENTORY "${PLAYBOOKS}/full.yml" --start-at-ask="$task" --limit syncopatedos
# done

for tag in "${todo}"; do
t=$(echo $tag | sd -s '\[\]' '')
echo $t
#ansible-playbook -C -i $INVENTORY "${PLAYBOOKS}/full.yml" --tag $t --limit lapbot
done

# alacritty, always, applications, asdf, audio, autofs, autologin, backgrounds, backup, barrier, base, bluetooth, cpupower, deadbeef, desktop, docker, dunst, env, firewall, fonts, full, gnome, groups, grub, gtk, htop, i3, icons, keybindings, keys, kitty, libvirt, lnav, media, menu, mirrors, mixxx, network, networkmanager, nfs, ntp, osc2midi, packages, pacman, picom, pipewire, profile, protokol, pulsar, python, qt, ranger, realtime, reaper, repo, rofi, rsyncd, rtirq, rtkit, ruby, scripts, setup, shell, sonicannotator, soniclineup, ssh, sshd, sudoers, sway, sxhkd, sysctl, terminal, testing, theme, thunar, tony, touchosc, tuned, tuning, updatedb, user, vagrant, vamp, video, vscode, wireless, xdg, xorg, zram
Loading

0 comments on commit c747241

Please sign in to comment.