### Setup PostgreSQL Database Tasks Source: https://docs.ansible.com/projects/ansible/latest/community/collection_contributors/collection_integration_add.html Installs required packages, initializes PostgreSQL, and starts the service. ```yaml - name: Install required packages package: name: - apt-utils - postgresql - postgresql-common - python3-psycopg2 - name: Initialize PostgreSQL shell: . /usr/share/postgresql-common/maintscripts-functions && set_system_locale && /usr/bin/pg_createcluster -u postgres 12 main args: creates: /etc/postgresql/12/ - name: Start PostgreSQL service ansible.builtin.service: name: postgresql state: started ``` -------------------------------- ### Install Database Example Playbook Source: https://docs.ansible.com/projects/ansible/latest/collections/check_point/mgmt/cp_mgmt_install_database_module.html This example demonstrates how to use the cp_mgmt_install_database module to copy the user database and network objects to specified Check Point targets. ```yaml - name: install-database cp_mgmt_install_database: targets: - checkpointhost1 - checkpointhost2 ``` -------------------------------- ### StartInstance with Authentication Source: https://docs.ansible.com/projects/ansible/latest/collections/community/sap_libs/sap_hostctrl_exec_module.html This example starts a SAP instance on a remote host, providing authentication credentials (username and password) and specifying instance details and options. ```yaml - name: StartInstance with authentication community.sap_libs.sap_hostctrl_exec: hostname: 192.168.8.15 username: tstadm password: test1234 function: StartInstance parameters: aInstance: mSid: 'TST' mSystemNumber: '01' aOptions: mTimeout: -1 # -1=synchronous, 0=async, >0=wait timeout in seconds mSoftTimeout: 0 mOptions: - O-INSTANCE ``` -------------------------------- ### Get Hardware Installed Information Source: https://docs.ansible.com/projects/ansible/latest/collections/hitachivantara/vspone_block/vsp.hv_storage_system_monitor_facts_module.html Retrieve information about installed hardware components. This example shows how to query for hardware details and optionally exclude component options. ```ansible - name: Get Hardware Installed information hitachivantara.vspone_block.vsp.hv_storage_system_monitor_facts: connection_info: address: storage1.company.com username: "admin" password: "secret" spec: query: "hardware_installed" include_component_option: false ``` -------------------------------- ### Get power status information Source: https://docs.ansible.com/projects/ansible/latest/collections/ieisystem/inmanage/power_status_info_module.html This example demonstrates how to get power status information using the ieisystem.inmanage.power_status_info module. It requires the 'inmanage' collection to be installed and configured with connection details. ```yaml - name: Power status test hosts: inmanage connection: local gather_facts: false vars: inmanage: host: "{{ ansible_ssh_host }}" username: "{{ username }}" password: "{{ password }}" tasks: - name: "Get power status information" ieisystem.inmanage.power_status_info: provider: "{{ inmanage }}" ``` -------------------------------- ### Example: Managing Apt Key and Repository Source: https://docs.ansible.com/projects/ansible/latest/collections/ansible/builtin/apt_key_module.html This example demonstrates a workflow where an APT key is first downloaded to a specific location, and then an APT repository is configured to use that key. This is useful for adding third-party repositories that require a specific signing key. ```yaml - name: One way to avoid apt_key once it is removed from your distro, armored keys should use .asc extension, binary should use .gpg block: - name: somerepo | no apt key ansible.builtin.get_url: url: https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x36a1d7869245c8950f966e92d8576a8ba88d21e9 dest: /etc/apt/keyrings/myrepo.asc checksum: sha256:bb42f0db45d46bab5f9ec619e1a47360b94c27142e57aa71f7050d08672309e0 - name: somerepo | apt source ansible.builtin.apt_repository: repo: "deb [arch=amd64 signed-by=/etc/apt/keyrings/myrepo.asc] https://download.example.com/linux/ubuntu {{ ansible_distribution_release }} stable" state: present ``` -------------------------------- ### Create a host with preferred location Source: https://docs.ansible.com/projects/ansible/latest/collections/ibm/storage_virtualize/ibm_svc_host_module.html This example shows how to create a host and assign it a preferred location and partition. ```yaml - name: Create a host with preferred location. ibm.storage_virtualize.ibm_svc_host: clustername: '{{ clustername }}' username: '{{ username }}' password: '{{ password }}' state: present name: host0 location: fs9500cl-2 partition: ha-partition-0 ``` -------------------------------- ### Get BIOS setup Source: https://docs.ansible.com/projects/ansible/latest/collections/ieisystem/inmanage/bios_info_module.html This example demonstrates how to use the ieisystem.inmanage.bios_info module to retrieve BIOS setup information. It requires the 'inmanage' collection and specifies connection details via a 'provider' dictionary. ```yaml - name: Bios test hosts: inmanage connection: local gather_facts: false vars: inmanage: host: "{{ ansible_ssh_host }}" username: "{{ username }}" password: "{{ password }}" tasks: - name: "Get bios setup" ieisystem.inmanage.bios_info: provider: "{{ inmanage }}" ``` -------------------------------- ### Get ACME plugin example Source: https://docs.ansible.com/projects/ansible/latest/collections/community/proxmox/proxmox_acme_plugin_info_module.html This example demonstrates how to retrieve information about a specific ACME plugin using its name. Ensure the `community.proxmox` collection is installed and the necessary API credentials or environment variables are configured. ```ansible - name: Get ACME plugin example community.proxmox.proxmox_acme_plugin_info: name: example ``` -------------------------------- ### Create a Host with Build Context Source: https://docs.ansible.com/projects/ansible/latest/collections/theforeman/foreman/host_module.html This example shows how to create a host and enable the build context, typically used for provisioning. ```yaml - name: "Create a host with build context" theforeman.foreman.host: username: "admin" password: "changeme" server_url: "https://foreman.example.com" name: "new_host" hostgroup: my_hostgroup build: true state: present ``` -------------------------------- ### Get BIOS Setup with inspur.ispim.bios_info Source: https://docs.ansible.com/projects/ansible/latest/collections/inspur/ispim/bios_info_module.html This Ansible playbook demonstrates how to use the inspur.ispim.bios_info module to retrieve BIOS setup information. Ensure the 'inspur.ispim' collection is installed and the necessary Python requirements are met on the target host. ```yaml - name: Bios test hosts: ism connection: local gather_facts: no vars: ism: host: "{{ ansible_ssh_host }}" username: "{{ username }}" password: "{{ password }}" tasks: - name: "Get bios setup" inspur.ispim.bios_info: provider: "{{ ism }}" ``` -------------------------------- ### Configure Boot Order Source: https://docs.ansible.com/projects/ansible/latest/collections/dellemc/openmanage/idrac_boot_module.html This example demonstrates how to set the sequence in which the system attempts to boot from available devices. Provide a list of boot option references in the desired order. ```yaml --- - name: Configure the boot order settings. dellemc.openmanage.idrac_boot: idrac_ip: "192.168.0.1" idrac_user: "user_name" idrac_password: "user_password" ca_path: "/path/to/ca_cert.pem" boot_order: - Boot0001 - Boot0002 - Boot0004 - Boot0003 ``` -------------------------------- ### Create hello-world Deployment Source: https://docs.ansible.com/projects/ansible/latest/collections/community/okd/openshift_route_module.html This example demonstrates how to create a basic deployment for a 'hello-world' application using the Kubernetes module. ```yaml - name: Create hello-world deployment community.okd.k8s: definition: apiVersion: apps/v1 kind: Deployment metadata: name: hello-kubernetes namespace: default spec: replicas: 3 selector: matchLabels: app: hello-kubernetes template: metadata: labels: app: hello-kubernetes spec: containers: - name: hello-kubernetes image: paulbouwer/hello-kubernetes:1.8 ports: - containerPort: 8080 ``` -------------------------------- ### Convert LDAP ObjectGuid to GUID String Source: https://docs.ansible.com/projects/ansible/latest/collections/microsoft/ad/as_guid_filter.html This example demonstrates how to use the `as_guid` filter with the `microsoft.ad.ldap` plugin to convert the raw `objectGuid` attribute from LDAP into a readable GUID string. Ensure the `microsoft.ad` collection is installed. ```yaml attributes: objectGuid: raw | microsoft.ad.as_guid ``` -------------------------------- ### Run 'install' target as root Source: https://docs.ansible.com/projects/ansible/latest/collections/community/general/make_module.html This example demonstrates running a specific target, 'install', and using `become: true` to execute it with root privileges. The `chdir` parameter specifies the project directory. ```yaml - name: Run 'install' target as root community.general.make: chdir: /home/ubuntu/cool-project target: install become: true ``` -------------------------------- ### Get all networks SM users softwares Source: https://docs.ansible.com/projects/ansible/latest/collections/cisco/meraki/networks_sm_users_softwares_info_module.html This example demonstrates how to retrieve a list of all software installed on SM-managed devices for a given network and user. ```APIDOC ## GET /networks/{networkId}/sm/users/softwares ### Description Retrieves a list of software for all devices in the given network installed by Systems Manager. ### Method GET ### Endpoint /networks/{networkId}/sm/users/softwares ### Parameters #### Query Parameters - **userId** (string) - Required - The ID of the user ### Response #### Success Response (200) - **meraki_response** (list) - A list of dictionaries, where each dictionary contains information about an installed software. - **appId** (string) - The unique identifier for the application. - **bundleSize** (integer) - The size of the application bundle in bytes. - **createdAt** (string) - The timestamp when the software was created. - **deviceId** (string) - The unique identifier for the device. - **dynamicSize** (integer) - The dynamic size of the application. - **id** (string) - The unique identifier for the software installation. - **identifier** (string) - The bundle identifier of the application. - **installedAt** (string) - The timestamp when the software was installed. - **toInstall** (boolean) - Indicates if the software is marked for installation. - **iosRedemptionCode** (boolean) - Indicates if an iOS redemption code is associated with the software. - **isManaged** (boolean) - Indicates if the software is managed by Meraki. - **itunesId** (string) - The iTunes ID of the application. - **licenseKey** (string) - The license key for the software. - **name** (string) - The name of the software. - **path** (string) - The path to the software on the device. - **redemptionCode** (integer) - The redemption code for the software. - **shortVersion** (string) - The short version string of the software. - **status** (string) - The installation status of the software. - **toUninstall** (boolean) - Indicates if the software is marked for uninstallation. - **uninstalledAt** (string) - The timestamp when the software was uninstalled. - **updatedAt** (string) - The timestamp when the software information was last updated. - **vendor** (string) - The vendor of the software. - **version** (string) - The version string of the software. ### Request Example ```python import meraki # Initialize the SDK meraki = meraki.Meraki( api_key="YOUR_MERAKI_API_KEY", base_url="https://api.meraki.com/api/v1" ) # Call the module result = meraki.networks_sm_users_softwares_info( networkId="your_network_id", userId="your_user_id" ) # Print the result print(result) ``` ### Response Example ```json [ { "appId": "string", "bundleSize": 0, "createdAt": "string", "deviceId": "string", "dynamicSize": 0, "id": "string", "identifier": "string", "installedAt": "string", "toInstall": true, "iosRedemptionCode": true, "isManaged": true, "itunesId": "string", "licenseKey": "string", "name": "string", "path": "string", "redemptionCode": 0, "shortVersion": "string", "status": "string", "toUninstall": true, "uninstalledAt": "string", "updatedAt": "string", "vendor": "string", "version": "string" } ] ``` ``` -------------------------------- ### Create Domain with Specific Parameters and Register Output Source: https://docs.ansible.com/projects/ansible/latest/collections/microsoft/ad/domain_module.html This example demonstrates creating a new Windows domain with detailed configuration, including database and SYSVOL paths, domain and forest modes, and DNS delegation settings. The output is registered for potential use in subsequent tasks, such as checking for reboot requirements. ```yaml - name: Create new Windows domain in a new forest with specific parameters and reboot in post task microsoft.ad.domain: create_dns_delegation: false database_path: C:\Windows\NTDS dns_domain_name: ansible.vagrant domain_mode: Win2012R2 domain_netbios_name: ANSIBLE forest_mode: Win2012R2 safe_mode_password: password123! sysvol_path: C:\Windows\SYSVOL register: domain_install ``` -------------------------------- ### Get Platform Information Source: https://docs.ansible.com/projects/ansible/latest/collections/check_point/mgmt/cp_mgmt_get_platform_module.html This example demonstrates how to retrieve the platform details for a specific gateway named 'gw1'. Ensure the 'check_point.mgmt' collection is installed and accessible. ```yaml - name: get-platform cp_mgmt_get_platform: name: gw1 ``` -------------------------------- ### Get all IPs under all IPAM Source: https://docs.ansible.com/projects/ansible/latest/collections/community/proxmox/proxmox_ipam_info_module.html This example demonstrates how to retrieve all IP addresses across all IPAMs. Ensure the community.proxmox collection is installed and the necessary Proxmox API credentials are configured. ```ansible - name: Get all IPs under all IPAM community.proxmox.proxmox_ipam_info: ``` -------------------------------- ### Create a website with multiple bindings and full configuration Source: https://docs.ansible.com/projects/ansible/latest/collections/microsoft/iis/website_module.html This example demonstrates creating a website with a specific site ID, multiple bindings (including HTTPS with SNI and CCS), and setting the application pool and physical path. ```yaml - name: Create a website with two bindings, set all values and start it microsoft.iis.website: name: WebSite site_id: 2 state: started physical_path: C:\wwwroot\websites\my-website application_pool: DefaultAppPool bindings: set: - ip: 127.0.0.1 port: 8081 hostname: my-website.com - ip: 127.0.0.2 port: 8082 hostname: my-website.net protocol: https use_sni: true use_ccs: false certificate_hash: 5409124040FA1C8FA74939BDA2EF8FD5975BD25B certificate_store_name: MY ``` -------------------------------- ### Get multiple packages with pagination and detail level Source: https://docs.ansible.com/projects/ansible/latest/collections/check_point/mgmt/cp_mgmt_package_facts_module.html This example demonstrates fetching a list of packages, specifying the detail level, and controlling the number of results and the starting offset. ```yaml - name: show-packages cp_mgmt_package_facts: details_level: standard limit: 50 offset: 0 ``` -------------------------------- ### Create VM with Cloud-Init (Username/Password) Source: https://docs.ansible.com/projects/ansible/latest/collections/community/proxmox/proxmox_kvm_module.html Create a VM using cloud-init for initial setup. This example configures a username, password, search domain, nameservers, and a network interface with IP configuration. ```yaml - name: Create new VM using cloud-init with a username and password community.proxmox.proxmox_kvm: node: sabrewulf name: spynal ide: ide2: 'local:cloudinit,format=qcow2' ciuser: mylinuxuser cipassword: supersecret searchdomains: 'mydomain.internal' nameservers: 1.1.1.1 net: net0: 'virtio,bridge=vmbr1,tag=77' ipconfig: ipconfig0: 'ip=192.168.1.1/24,gw=192.168.1.1' ``` -------------------------------- ### Power restore test Source: https://docs.ansible.com/projects/ansible/latest/collections/kaytus/ksmanage/power_restore_info_module.html This example demonstrates how to get power restore information using the kaytus.ksmanage.power_restore_info module. Ensure the 'ksmanage' collection is installed and configured with the necessary provider details. ```yaml - name: Power restore test hosts: ksmanage connection: local gather_facts: false vars: ksmanage: host: "{{ ansible_ssh_host }}" username: "{{ username }}" password: "{{ password }}" tasks: - name: "Get power restore information" kaytus.ksmanage.power_restore_info: provider: "{{ ksmanage }}" ``` -------------------------------- ### Start a libvirt network Source: https://docs.ansible.com/projects/ansible/latest/collections/community/libvirt/virt_net_module.html This example shows how to start a previously defined libvirt network by specifying the 'create' command and the network name. ```yaml - name: Start a network community.libvirt.virt_net: command: create name: br_nat ``` -------------------------------- ### Get hard disk information Source: https://docs.ansible.com/projects/ansible/latest/collections/kaytus/ksmanage/hard_disk_info_module.html This example demonstrates how to use the `kaytus.ksmanage.hard_disk_info` module to retrieve hard disk information. It requires the `ksmanage` collection to be installed and configured with connection details. ```yaml - name: Hard disk test hosts: ksmanage connection: local gather_facts: false vars: ksmanage: host: "{{ ansible_ssh_host }}" username: "{{ username }}" password: "{{ password }}" tasks: - name: "Get hard disk information" kaytus.ksmanage.hard_disk_info: provider: "{{ ksmanage }}" ``` -------------------------------- ### Create database with customizations Source: https://docs.ansible.com/projects/ansible/latest/collections/lowlydba/sqlserver/database_module.html This example demonstrates creating a database with specific configurations for owner, MAXDOP, and recovery model. Adjust parameters like `owner`, `maxdop`, and `recovery_model` as needed. ```yaml - name: Create database with customizations lowlydba.sqlserver.database: sql_instance: sql-01.myco.io database: LowlyDB owner: sa maxdop: 2 recovery_model: Simple ``` -------------------------------- ### Install Policy Example Source: https://docs.ansible.com/projects/ansible/latest/collections/check_point/mgmt/cp_mgmt_install_policy_module.html This example demonstrates how to install the Access Control and Threat Prevention policies for a specified policy package on a target gateway. Ensure the 'check_point.mgmt' collection is installed and the module is invoked with the correct parameters. ```yaml - name: install-policy cp_mgmt_install_policy: access: true policy_package: standard targets: - corporate-gateway threat_prevention: true ``` -------------------------------- ### Get DNS Information Source: https://docs.ansible.com/projects/ansible/latest/collections/kaytus/ksmanage/dns_info_module.html This example demonstrates how to use the `kaytus.ksmanage.dns_info` module to retrieve DNS information. It requires the `ksmanage` collection to be installed and configured with host, username, and password variables. ```yaml - name: DNS test hosts: ksmanage connection: local gather_facts: false vars: ksmanage: host: "{{ ansible_ssh_host }}" username: "{{ username }}" password: "{{ password }}" tasks: - name: "Get dns information" kaytus.ksmanage.dns_info: provider: "{{ ksmanage }}" ``` -------------------------------- ### Start Docker Container with Storage Options Source: https://docs.ansible.com/projects/ansible/latest/collections/community/docker/docker_container_module.html This example demonstrates how to start a Docker container with specific storage options, such as limiting the root filesystem size. Note that this may require special storage backends. ```yaml name: Start container with storage options community.docker.docker_container: name: test image: ubuntu:18.04 state: started storage_opts: # Limit root filesystem to 12 MB - note that this requires special storage backends # (https://fabianlee.org/2020/01/15/docker-use-overlay2-with-an-xfs-backing-filesystem-to-limit-rootfs-size/) size: 12m ``` -------------------------------- ### Get session information Source: https://docs.ansible.com/projects/ansible/latest/collections/ieisystem/inmanage/session_info_module.html This example demonstrates how to use the ieisystem.inmanage.session_info module to retrieve session details. It requires the 'inmanage' collection to be installed and configured with host, username, and password variables. ```yaml - name: Session test hosts: inmanage connection: local gather_facts: false vars: inmanage: host: "{{ ansible_ssh_host }}" username: "{{ username }}" password: "{{ password }}" tasks: - name: "Get session information" ieisystem.inmanage.session_info: provider: "{{ inmanage }}" ``` -------------------------------- ### Create Table Examples Source: https://docs.ansible.com/projects/ansible/latest/collections/community/postgresql/postgresql_table_module.html Examples demonstrating how to create PostgreSQL tables with various configurations. ```APIDOC ## Create Table ### Description Creates a PostgreSQL table with specified columns, owner, tablespace, and other properties. ### Method community.postgresql.postgresql_table ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **name** (string) - Required - The name of the table to create. Can include schema name (e.g., `acme.foo`). - **login_db** (string) - Optional - The database to connect to. - **like** (string) - Optional - The name of an existing table to use as a template for the new table's DDL. - **owner** (string) - Optional - The owner of the table. - **columns** (list of strings) - Optional - A list of column definitions (e.g., `id serial primary key`). - **tablespace** (string) - Optional - The tablespace for the table. - **including** (list of strings) - Optional - Specifies additional elements to include from the `like` table (e.g., `comments`, `indexes`). - **storage_params** (list of strings) - Optional - Storage parameters for the table (e.g., `fillfactor=100`). - **unlogged** (boolean) - Optional - If true, creates an unlogged table (available from PostgreSQL 9.1). - **state** (string) - Optional - Desired state of the table. Use `present` for creation. - **cascade** (boolean) - Optional - If true, drops dependent objects when dropping the table. - **truncate** (boolean) - Optional - If true, truncates the table after creation or if it already exists. ### Request Example ```yaml - name: Create tbl2 in the acme database with the DDL like tbl1 with testuser as an owner community.postgresql.postgresql_table: login_db: acme name: tbl2 like: tbl1 owner: testuser - name: Create test_table with several columns in ssd tablespace with fillfactor=10 and autovacuum_analyze_threshold=1 community.postgresql.postgresql_table: name: test_table columns: - id bigserial primary key - num bigint - stories text tablespace: ssd storage_params: - fillfactor=10 - autovacuum_analyze_threshold=1 - name: Create an unlogged table in schema acme community.postgresql.postgresql_table: name: acme.useless_data columns: waste_id int unlogged: true - name: Create table with composite primary key community.postgresql.postgresql_table: name: composite_pk_table columns: - id bigserial - num bigint - primary key (id, num) ``` ### Response #### Success Response (200) - **owner** (string) - Table owner. - **queries** (list of strings) - List of executed queries. - **state** (string) - Table state. - **storage_params** (list of strings) - Storage parameters. - **table** (string) - Name of the table. - **tablespace** (string) - Tablespace. #### Response Example ```json { "owner": "postgres", "queries": ["CREATE TABLE \"test_table\" (id bigint)"], "state": "present", "storage_params": ["fillfactor=100", "autovacuum_analyze_threshold=1"], "table": "test_table", "tablespace": "ssd_tablespace" } ``` ``` -------------------------------- ### Get power restore information Source: https://docs.ansible.com/projects/ansible/latest/collections/ieisystem/inmanage/power_restore_info_module.html This example demonstrates how to use the ieisystem.inmanage.power_restore_info module to retrieve power restore information. It requires the 'inmanage' collection to be installed and configured with connection details. ```yaml - name: Power restore test hosts: inmanage connection: local gather_facts: false vars: inmanage: host: "{{ ansible_ssh_host }}" username: "{{ username }}" password: "{{ password }}" tasks: - name: "Get power restore information" ieisystem.inmanage.power_restore_info: provider: "{{ inmanage }}" ``` -------------------------------- ### Get DNS Information Source: https://docs.ansible.com/projects/ansible/latest/collections/ieisystem/inmanage/dns_info_module.html This example demonstrates how to use the ieisystem.inmanage.dns_info module to retrieve DNS information from an inManage server. It requires the 'inmanage' collection to be installed and configured with connection details. ```yaml - name: DNS test hosts: inmanage connection: local gather_facts: false vars: inmanage: host: "{{ ansible_ssh_host }}" username: "{{ username }}" password: "{{ password }}" tasks: - name: "Get dns information" ieisystem.inmanage.dns_info: provider: "{{ inmanage }}" ``` -------------------------------- ### Start Server and Wait for SSH Host Keys Source: https://docs.ansible.com/projects/ansible/latest/collections/cloudscale_ch/cloud/server_module.html This example starts a server and includes logic to wait for SSH host keys to be generated. It uses `register` to capture server information and `until` with `retries` and `delay` to poll for the condition. The server will not be considered ready until the SSH host keys are available. ```yaml - name: Start server and wait for SSH host keys cloudscale_ch.cloud.server: name: my-cloudscale-server-with-ssh-key image: debian-10 flavor: flex-4-2 ssh_keys: - ssh-rsa XXXXXXXXXX...XXXX ansible@cloudscale api_token: xxxxxx register: server until: server is not failed retries: 5 delay: 2 ``` -------------------------------- ### Get ACME account example Source: https://docs.ansible.com/projects/ansible/latest/collections/community/proxmox/proxmox_acme_account_info_module.html This snippet demonstrates how to retrieve information for a specific ACME account. Ensure the `community.proxmox` collection is installed and the necessary Proxmox VE API credentials are configured. ```ansible - name: Get ACME account example community.proxmox.proxmox_acme_account_info: name: example ```