Skip to content

Instantly share code, notes, and snippets.

View nleiva's full-sized avatar
☠️
Working from somewhere

Nicolas Leiva nleiva

☠️
Working from somewhere
View GitHub Profile
@nleiva
nleiva / ansible.go
Last active September 14, 2020 17:17
// ModuleArgs are the module inputs
type ModuleArgs struct {
Time string
}
func main() {
...
argsFile := os.Args[1]
text, err := ioutil.ReadFile(argsFile)
...
@nleiva
nleiva / busy.go
Created September 14, 2020 15:26
func isItBusy(min string) (bool, error) {
...
// max -> min.Add(1 * time.Hour)
max, err := maxTime(min)
// ...
srv, err := calendar.New(client)
// ...
freebusyRequest := calendar.FreeBusyRequest{
TimeMin: min,
TimeMax: max,
- name: Run Go container
podman_container:
name: go_test_container
image: golang
command: go version
rm: true
log_options: "path={{ log_file }}"
@nleiva
nleiva / next_task.yml
Last active September 10, 2020 20:04
tasks:
- shell: echo "Run this only when not busy!"
when: not output.busy
ok: [localhost] => {
"output": {
"busy": true,
"changed": false,
"failed": false,
"msg": "The timeslot 2020-09-02T17:53:43Z is busy: true"
}
}
- name: Check if timeslot is taken
calendar:
time: "{{ ansible_date_time.iso8601 }}"
register: output
- name: Wait until we can SSH to the target from the Test Host
wait_for:
host: "{{ ansible_host }}"
port: 22
state: started
timeout: 30
delegate_to: "{{ test_host }}"
- name: Run Capirca Module
nleiva.capirca_acl.translate:
platform: 'iptables'
filter_options:
- 'INPUT'
- 'ACCEPT'
def_folder: "sample"
pol_file: "sample/terms.pol"
tasks:
- name: Save current iptables rules
shell: iptables-save > /tmp/iptables-rules-backup.txt
- name: Schedule iptables-restore to execute in 20 minutes as root
at:
command: iptables-restore < /tmp/iptables-rules-backup.txt
count: 20
units: minutes
vars:
map:
ios: "cisco"
junos: "juniper"
CentOS: "iptables"
RedHat: "iptables"
tasks:
- name: Set platform for Networking devices
set_fact: