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
"ansible_facts.disks": [
{
"bootable": true,
"bus_type": "SAS",
"clustered": false,
"firmware_version": "1.0 ",
"friendly_name": "VMware Virtual disk",
"guid": "{60c01450-65ba-4ecf-9049-f6e5a8e511db}",
"location": "SCSI0",
"manufacturer": "VMware ",
- name: Generate the report
uri:
method: GET
return_content: yes
status_code: 200
user: "reporting_user"
password: "superduperpassword"
force_basic_auth: yes
url: "https://kibana.domain:5601{{ genreport.json.path }}"
dest: /tmp/test-max-cpu-stats-prod-wm.pdf
{% for files in [
{'cis': '5.3.3 Ensure password reuse is limited (Scored)', 'name': 'pwquality'},
{'cis': '5.3.4 Ensure password hashing algorithm is SHA-512 (Scored)', 'name': 'unix'}
]
%}
{{ files.cis }}:
file.managed:
- source: salt://files/pam/{{files.name}}
- name: /usr/share/pam-configs/{{files.name}}

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
#####################
# PREREQUISITES
#####################
Write-Host @'
=============================
< Windows Subsystem for Linux >
< (Ubuntu >= 18.04) installer >
=============================
\
##
## 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
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
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
for item in example['recordsInPage']:
for networks in item['publicAddresses']:
if "10.0.0.0/16" in networks:
print(item)
- 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 %}