Skip to content

Instantly share code, notes, and snippets.

View metabsd's full-sized avatar
🏠
Working from home

Benoit Martin metabsd

🏠
Working from home
View GitHub Profile
- name: "Network Policy"
mymodule:
data:
displayName: "astring"
tags:
- name: "anotherstring"
strValue: "anothersuperstring"
state: present
{
"temp_var | from_yaml": [
{
"name": "Project",
"strValue": "mm-uc-dev"
}
],
"_ansible_verbose_always": true,
"_ansible_no_log": false,
"changed": false,
- name: Network Policy
vars:
temp_var: |
{% if item.source_project != "N/A" %}
- name: "Project"
strValue: "{{ item.source_project }}"
{% endif %}
{% if item.source_sectag != "N/A" %}
- name: "sectag"
strValue: "{{ item.source_sectag }}"
- name: Network Policy
mymodule:
data:
displayName: "{%- if item.source_project != 'N/A' -%}{{ item.source_project }}{%- endif -%}
{%- if item.source_sectag != 'N/A' -%}.{{ item.source_sectag }}{%- endif -%}"
tags: |
{% if item.source_project != 'N/A' %}
- name: "Project"
strValue: "{{ item.source_project }}"
{% endif %}
for item in example['recordsInPage']:
for networks in item['publicAddresses']:
if "10.0.0.0/16" in networks:
print(item)
Final result : q=project%3D%3D%22mm-uc-dev%22%20and%20sectag%3D%3D%22mm-app%22
Not encoded : {"q":"Project==\"mm-uc-dev\" and sectag==\"mm-app\""}
Input : [{'name': 'project', 'value': 'project1},{'name': 'sectag', 'value': 'sectag1'}]
q = name + "%3D%3D%22" + value + "%22%20" + "and" + (next item on the loop) "%20s" + name + "%3D%3D%22" + value (If the last one add) + "%22" at the end
Another example
4.261 INFO Updating inventory 18: Netbox Inv Test
4.301 ERROR Number of licensed instances exceeded, would bring available instances to 713, system is licensed for 100.
See http://www.ansible.com/renew for license extension information.
6.117 DEBUG Using base command: python /opt/cust_venv/iaas_na/bin/ansible-inventory -i /tmp/awx_60391_azati6wn/project/inventories/bundle_int_test_netbox_inventory_sync.yml --playbook-dir /tmp/awx_60391_azati6wn/project/inventories -vvvvv
6.117 INFO Reading Ansible inventory source: /tmp/awx_60391_azati6wn/project/inventories/bundle_int_test_netbox_inventory_sync.yml
6.122 INFO Using VIRTUAL_ENV: /opt/cust_venv/iaas_na/
6.122 INFO Using PATH: /opt/cust_venv/iaas_na/bin:/var/lib/awx/venv/awx/bin:/opt/rh/rh-postgresql10/root/usr/bin:/opt/rh/rh-python36/root/usr/bin:/var/lib/awx/venv/awx/bin:/var/lib/awx/venv/awx/bin:/opt/rh/rh-postgresql10/root/usr/bin:/opt/rh/rh-python36/root/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
##
## Arch Linux repository mirrorlist
## Filtered by mirror score from mirror status page
## Generated on 2020-03-17
##
## Canada
#Server = http://archlinux.mirror.colo-serv.net/$repo/os/$arch
## Canada
#Server = http://mirror.scd31.com/arch/$repo/os/$arch
#####################
# PREREQUISITES
#####################
Write-Host @'
=============================
< Windows Subsystem for Linux >
< (Ubuntu >= 18.04) installer >
=============================
\

salt-call --versions-report

root@saltmaster:/srv/salt/system/cis# salt-call --versions-report
Salt Version:
           Salt: 2018.3.2

Dependency Versions:
           cffi: Not Installed
       cherrypy: Not Installed
       dateutil: 2.4.2