Skip to content

Instantly share code, notes, and snippets.

View tjtoml's full-sized avatar

Tyler Tomlinson tjtoml

View GitHub Profile
@tjtoml
tjtoml / when.yml
Created October 5, 2020 16:26
convulted when statement
- name: Som action
win_shell: blah blah
when: '["C:\company\flag_files\", item.name, "-", item.cust_num, "-", release_version, "-", "installed.txt"]|join("") not in (env_flag_files.files|map(attribute="path")|list)'
## (env_flag_files.files|map(attribute="path")|list)' evals to
- C:\company\flag_files\test2-4321-5.2-installed.txt
- C:\company\flag_files\test1-1234-5.2-installed.txt
## error output
@tjtoml
tjtoml / out.yml
Created September 7, 2020 22:25
ansible_file_contents
ok: [] =>
msg:
- ansible_loop_var: item
changed: false
cmd: cat /etc/db_flag_files/cust1-1234
delta: '0:00:00.003117'
end: '2020-09-07 22:21:53.727129'
failed: false
invocation:
module_args:
@tjtoml
tjtoml / desired-output.txt
Last active September 7, 2020 19:35
ansible looping
#path /tmp/test1.txt
test1
test1-foo
test1-bar
3000
#path /tmp/test2.txt
test2
@tjtoml
tjtoml / task.yml
Created July 9, 2020 14:16
Variables in conditional
- name: Apply the .sql scripts to create the database tables
postgresql_query:
db: vendor-{{ item.0.name }}-{{ item.0.cust_num }}
path_to_script: "{{ item.1.path }}"
loop: "{{ vendor_sites|product(table_scripts.files)|list }}"
loop_control:
label: "{{ item.0.name }}-{{ item.0.cust_num }} - {{ item.1.path|regex_search('[^/]*$') }}"
when: table-{{ item.0.name }}-{{ item.0.cust_num }}-{{ item.1.path|regex_search('[^/]*$') }} not in db_flag_files.files
@tjtoml
tjtoml / sites.yml
Created July 8, 2020 18:12
ansible_question
---
sites:
- name: site1
cust_num: 1234
- name: site2
cust_num: 4321
---
- hosts: application_servers
remote_user: root
become: true
become_method: su
vars_files:
- vars/naming_convention.yml
tasks:
#Server = http://mirrors.evowise.com/archlinux/$repo/os/$arch
Server = http://mirrors.kernel.org/archlinux/$repo/os/$arch
Server = http://arch.mirror.constant.com/$repo/os/$arch
Server = http://mirror.hackingand.coffee/arch/$repo/os/$arch
Server = http://arlm.tyzoid.com/$repo/os/$arch
Server = http://mirrors.sorengard.com/archlinux/$repo/os/$arch
Server = https://mirror.umd.edu/archlinux/$repo/os/$arch
[env_01]
10.14.66.10 vcpu_count=8 ram_mb=35 APP
10.14.66.11 ram_mb=25 vcpu_count=9 SQL
10.14.66.12 ram_mb=45 vcpu_count=7 custom_var=blah WTS
10.14.66.13 custom_var=blahblah ram_mb=356 vcpu_count=26 aaa
10.14.66.14 bbb
10.14.66.15 ccc
10.14.66.16 ddd
10.14.66.17 eee
10.14.66.18 fff
@tjtoml
tjtoml / hosts.ini
Last active May 6, 2019 20:11
hostvars problem
[dhcp_server]
10.14.66.2
[env_01]
10.14.66.11
10.14.66.12
10.14.66.13
[sql_servers]
10.14.66.11
tasks:
- include_vars: vault.yml
- include_role:
name: repo-ansible-role
- include_role:
name: geerlingguy.nodejs
vars:
nodejs_npm_global_packages:
- verdaccio
- verdaccio-ldap