mirror of
https://gitea.com/mcereda/oam.git
synced 2026-02-09 05:44:23 +00:00
chore(ansible/examples): add the proper ternary operator
This commit is contained in:
@@ -1,2 +1,3 @@
|
||||
ansible/playbooks/aws.ec2.enable-ssm-agent.yml package-latest
|
||||
ansible/playbooks/keybase.register-device.yml no-changed-when
|
||||
examples/ansible/aws_ec2.yml yaml[comments-indentation]
|
||||
|
||||
@@ -29,3 +29,7 @@ indent_size = 4
|
||||
|
||||
[*.ts]
|
||||
indent_size = 4
|
||||
|
||||
[Makefile]
|
||||
indent_style = tab
|
||||
tab_width = 4
|
||||
|
||||
@@ -26,8 +26,9 @@ lint:
|
||||
parallel: true
|
||||
commands:
|
||||
ansible: &ansible-lint
|
||||
glob: '*ansible*'
|
||||
run: .venv/bin/ansible-lint
|
||||
files: find . -type f -path "*ansible*" -not -path "*venv*"
|
||||
glob: '*.{yaml,yml}'
|
||||
run: .venv/bin/ansible-lint {files}
|
||||
docker: &hadolint
|
||||
# The official docker image is based on scratch and only takes only one
|
||||
# input file at a time. I have no clue how to fix that for now so let's
|
||||
|
||||
6
Makefile
6
Makefile
@@ -5,8 +5,12 @@ override venv ?= ${shell git rev-parse --show-toplevel}/.venv
|
||||
create-venv: override python_version ?= 3.12
|
||||
create-venv: ${shell which 'python${python_version}'}
|
||||
@python${python_version} -m 'venv' '${venv}'
|
||||
@source '${venv}/bin/activate' && pip --require-virtualenv install -r 'requirements.txt'
|
||||
@${venv}/bin/pip --require-virtualenv install -U -r 'requirements.txt'
|
||||
|
||||
recreate-venv:
|
||||
@rm -r '${venv}'
|
||||
@${MAKE} create-venv
|
||||
|
||||
update-venv: ${venv}/bin/pip
|
||||
@${venv}/bin/pip freeze -l --require-virtualenv | sed 's/==/>=/' \
|
||||
| xargs ${venv}/bin/pip --require-virtualenv install -U
|
||||
|
||||
@@ -37,15 +37,15 @@
|
||||
dest: /etc/knockd.conf
|
||||
content: |
|
||||
[options]
|
||||
UseSyslog
|
||||
Interface = {{ ansible_default_ipv4.alias }}
|
||||
UseSyslog
|
||||
Interface = {{ ansible_default_ipv4.alias }}
|
||||
|
||||
[openClose7777]
|
||||
sequence = 2222:udp,3333:tcp,4444:udp
|
||||
seq_timeout = 15
|
||||
tcpflags = syn
|
||||
cmd_timeout = 10
|
||||
start_command = /usr/bin/firewall-cmd --add-port=7777/tcp --zone=public
|
||||
stop_command = /usr/bin/firewall-cmd --remove-port=7777/tcp --zone=public
|
||||
sequence = 2222:udp,3333:tcp,4444:udp
|
||||
seq_timeout = 15
|
||||
tcpflags = syn
|
||||
cmd_timeout = 10
|
||||
start_command = /usr/bin/firewall-cmd --add-port=7777/tcp --zone=public
|
||||
stop_command = /usr/bin/firewall-cmd --remove-port=7777/tcp --zone=public
|
||||
backup: true
|
||||
mode: '0600'
|
||||
|
||||
@@ -99,7 +99,9 @@
|
||||
minute: 0
|
||||
hour: 3 # 3 AM
|
||||
weekday: 0 # Sunday
|
||||
job: docker ps -f 'name=pihole' -f 'status=running' -f 'health=healthy' -q | xargs -I{} docker exec {} pihole -g
|
||||
job: >-
|
||||
docker ps -f 'name=pihole' -f 'status=running' -f 'health=healthy' -q
|
||||
| xargs -I{} docker exec {} pihole -g
|
||||
- name: Create the cron job for automatic backups
|
||||
tags:
|
||||
- backup
|
||||
@@ -119,9 +121,10 @@
|
||||
- graviton
|
||||
community.docker.docker_container_exec:
|
||||
container: pihole
|
||||
command: >
|
||||
command: >-
|
||||
sqlite3 '/etc/pihole/gravity.db'
|
||||
"INSERT OR IGNORE INTO adlist (address, enabled, comment) VALUES ('{{ item }}', 1, 'Listed on v.firebog.net');"
|
||||
"INSERT OR IGNORE INTO adlist (address, enabled, comment)
|
||||
VALUES ('{{ item }}', 1, 'Listed on v.firebog.net');"
|
||||
# on M1 macs execute `export NO_PROXY=*` first
|
||||
loop: "{{ lookup('ansible.builtin.url', 'https://v.firebog.net/hosts/lists.php?type=tick', wantlist=True) }}"
|
||||
async: 600
|
||||
|
||||
@@ -11,6 +11,24 @@
|
||||
- name: Get back a conditional value.
|
||||
ansible.builtin.debug:
|
||||
var: "{{ 'true' if 'test me a lot' is match('test') else 'false' }}"
|
||||
- name: Use the ternary operator.
|
||||
ansible.builtin.debug:
|
||||
msg: >-
|
||||
{{
|
||||
'test me a lot' is match('test')
|
||||
| ternary(
|
||||
'what_if_true',
|
||||
'what_if_false'
|
||||
)
|
||||
}}
|
||||
{{
|
||||
'test me a lot' is match('test')
|
||||
| ternary(
|
||||
'what_if_true',
|
||||
'what_if_false',
|
||||
'what_if_null'
|
||||
)
|
||||
}}
|
||||
|
||||
# Returns ["string"] from ["", "string", 0, false].
|
||||
- name: Remove empty or false values from a list piping it to 'select()'.
|
||||
@@ -118,6 +136,19 @@
|
||||
- "{{ resource_url is search('USERS', ignorecase=true) }}"
|
||||
- "{{ resource_url is regex('example\\.com/\\w+/foo') }}"
|
||||
|
||||
- name: Get specific lines from walls of text.
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ previous_task.stdout | regex_findall('Infra Phase complete, .*') }}"
|
||||
- name: Test specific lines from walls of text.
|
||||
ansible.builtin.debug:
|
||||
msg: >-
|
||||
{{
|
||||
(
|
||||
previous_task.stdout
|
||||
| regex_findall('Infra Phase complete, .*')
|
||||
) is not search('0/')
|
||||
}}"
|
||||
|
||||
- name: Show off Ansible's loops
|
||||
hosts: all
|
||||
tasks:
|
||||
|
||||
@@ -11,11 +11,12 @@
|
||||
1. [_No extensions found_ when running from source](#no-extensions-found-when-running-from-source)
|
||||
1. [_Type the name and password of a user in the 'Developer Tools' group to allow Developer Tools Access to make changes_ on Mac OS X](#type-the-name-and-password-of-a-user-in-the-developer-tools-group-to-allow-developer-tools-access-to-make-changes-on-mac-os-x)
|
||||
1. [Further readings](#further-readings)
|
||||
1. [Sources](#sources)
|
||||
1. [Sources](#sources)
|
||||
|
||||
## Configuration
|
||||
|
||||
The configuration consists of the application's defaults, overridden by the user settings first and, if existing, by the workspace settings.<br/>
|
||||
The configuration consists of the application's defaults, overridden by the user settings first and, if existing, by the
|
||||
workspace settings.<br/>
|
||||
See the [settings.json] example.
|
||||
|
||||
The user configuration is loaded from the `settings.json` file in the user's configuration directory for the application.
|
||||
@@ -43,16 +44,17 @@ Built-in:
|
||||
|
||||
Extensions:
|
||||
|
||||
| Extension | Setting | Default value | Scopes | Location in tree | Description |
|
||||
| -------------------------- | --------------------------------------------- | ------------- | --------------- | -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| vscode.git (built-in) | `git.autofetch` | `true` | User, Workspace | Extensions > Git | When set to true, commits will automatically be fetched from the default remote of the current Git repository. Setting to `all` will fetch from all remotes. |
|
||||
| angelo-breuer.clock | `clock.alignment` | `"Left"` | User, Workspace | Extensions > Status Bar Clock | Alignment of the clock on the status bar. |
|
||||
| angelo-breuer.clock | `clock.format` | `"hh:MM"` | User, Workspace | Extensions > Status Bar Clock | Date and time format. See <https://www.npmjs.com/package/dateformat#mask-options> for more options. |
|
||||
| yzhang.markdown-all-in-one | `markdown.extension.orderedList.autoRenumber` | `true` | User, Workspace | Extensions > Markdown All In One | Auto fix ordered list markers. |
|
||||
| yzhang.markdown-all-in-one | `markdown.extension.orderedList.marker` | `"ordered"` | User, Workspace | Extensions > Markdown All In One | Auto fix ordered list markers. |
|
||||
| yzhang.markdown-all-in-one | `markdown.extension.toc.levels` | `"1..6"` | User, Workspace | Extensions > Markdown All In One | Range of levels for the ToC. |
|
||||
| yzhang.markdown-all-in-one | `markdown.extension.toc.orderedList` | `false` | User, Workspace | Extensions > Markdown All In One | Use an ordered list in the ToC. |
|
||||
| redhat.ansible | `redhat.telemetry.enabled` | `true` | User, Workspace | Extensions > Ansible | Send telemetry to Red Hat servers. |
|
||||
| Extension | Setting | Default value | Scopes | Location in tree | Description |
|
||||
| -------------------------- | --------------------------------------------- | ------------- | --------------- | --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| vscode.git (built-in) | `git.autofetch` | `true` | User, Workspace | Extensions > Git | When set to true, commits will automatically be fetched from the default remote of the current Git repository. Setting to `all` will fetch from all remotes. |
|
||||
| angelo-breuer.clock | `clock.alignment` | `"Left"` | User, Workspace | Extensions > Status Bar Clock | Alignment of the clock on the status bar. |
|
||||
| angelo-breuer.clock | `clock.format` | `"hh:MM"` | User, Workspace | Extensions > Status Bar Clock | Date and time format. See <https://www.npmjs.com/package/dateformat#mask-options> for more options. |
|
||||
| yzhang.markdown-all-in-one | `markdown.extension.orderedList.autoRenumber` | `true` | User, Workspace | Extensions > Markdown All In One | Auto fix ordered list markers. |
|
||||
| yzhang.markdown-all-in-one | `markdown.extension.orderedList.marker` | `"ordered"` | User, Workspace | Extensions > Markdown All In One | Auto fix ordered list markers. |
|
||||
| yzhang.markdown-all-in-one | `markdown.extension.toc.levels` | `"1..6"` | User, Workspace | Extensions > Markdown All In One | Range of levels for the ToC. |
|
||||
| yzhang.markdown-all-in-one | `markdown.extension.toc.orderedList` | `false` | User, Workspace | Extensions > Markdown All In One | Use an ordered list in the ToC. |
|
||||
| redhat.ansible | `redhat.telemetry.enabled` | `true` | User, Workspace | Extensions > Ansible > Telemetry | Send telemetry to Red Hat servers. |
|
||||
| redhat.ansible | `ansible.validation.lint.enabled` | `true` | User, Workspace | Extensions > Ansible > Validation | USe ansible-lint if found to lint Ansible files. Kinda a nuisance when enabled. |
|
||||
|
||||
## Handy keyboard shortcuts
|
||||
|
||||
@@ -140,7 +142,7 @@ sudo dscl . append '/Groups/_developer' GroupMembership "$USER"
|
||||
- [Documentation]
|
||||
- [Network connections in Visual Studio Code]
|
||||
|
||||
## Sources
|
||||
### Sources
|
||||
|
||||
- [Using extensions in compiled VSCode]
|
||||
- [Recommending VSCode extensions within your Open Source projects]
|
||||
@@ -148,6 +150,7 @@ sudo dscl . append '/Groups/_developer' GroupMembership "$USER"
|
||||
- [VSCode (and some non-patched Electron applications) doesn't run after Tumbleweed update on Nvidia]
|
||||
- [Electron applications all crash upon launch]
|
||||
- [Authorize a non-admin developer in Xcode / Mac OS]
|
||||
- [Deep dive on Ansible VScode extension]
|
||||
|
||||
<!--
|
||||
References
|
||||
@@ -164,6 +167,7 @@ sudo dscl . append '/Groups/_developer' GroupMembership "$USER"
|
||||
|
||||
<!-- Others -->
|
||||
[authorize a non-admin developer in xcode / mac os]: https://stackoverflow.com/questions/1837889/authorize-a-non-admin-developer-in-xcode-mac-os#1837935
|
||||
[deep dive on ansible vscode extension]: https://www.ansible.com/blog/deep-dive-on-ansible-vscode-extension/
|
||||
[electron applications all crash upon launch]: https://bugs.launchpad.net/ubuntu/+source/glibc/+bug/1944468
|
||||
[recommending vscode extensions within your open source projects]: https://tattoocoder.com/recommending-vscode-extensions-within-your-open-source-projects/
|
||||
[using extensions in compiled vscode]: https://stackoverflow.com/questions/44057402/using-extensions-in-compiled-vscode#45291490
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
ansible==9.4.0
|
||||
ansible==9.5.1
|
||||
ansible-lint==24.2.2
|
||||
click==8.1.7
|
||||
pyinilint==0.17
|
||||
|
||||
Reference in New Issue
Block a user