I have a playbook where I want to create a list from data and pass the newly created list
This is my playbook.
playbook.yml
---
- name: Global Objects
hosts: check_point
connection: httpapi
gather_facts: False
vars_files:
- 'credentials/my_var.yml'
- 'credentials/login.yml'
tasks:
- name: read-file
include_vars:
file: tmp/task.yml
- name: make-existing-host-a member
check_point.mgmt.cp_mgmt_group:
name: gTest1A
members:
- "{{ new_list_created }}"
- "{{ unique_host }}"
auto_publish_session: true
loop: "{{ members }}"
delegate_to: Global
ignore_errors: yes
The idea is to create a list from my task.yml called new_list_created and parse that list as a member to
members:
- "{ new_list_created }"
Below is the list I wanted to apply Jinja2 filter. It contains a list of so many things I want to filter.
task.yml
color: black
comments: Comments
domain:
domain-type: mds
name: System Data
uid: a0eebc99-afed-4ef8-bb6d-fedfedfedfed
groups: []
icon: General/group
members:
- color: black
comments: FWP - Testing this
domain:
domain-type: mds
name: System Data
uid: a0eebc99-afed-4ef8-bb6d-fedfedfedfed
groups:
- 603dab88-43a2-437a-b59f-0bee45d769c1
icon: Objects/host
interfaces: []
ipv4-address: 10.1.2.3
meta-info:
creation-time:
iso-8601: 2021-04-09T11:31-0400
posix: 1617982299819
creator: SVCFWPWorker
last-modifier: SVCFWPWorker
last-modify-time:
iso-8601: 2021-04-23T13:05-0400
posix: 1619197548306
lock: unlocked
validation-state: ok
name: gTest101
nat-settings:
auto-rule: false
read-only: false
tags: []
type: host
uid: e12b3f3c-8afd-441f-a5e0-75f399605836
- color: black
comments: FWP - Applying this
domain:
domain-type: mds
name: System Data
uid: a0eebc99-afed-4ef8-bb6d-fedfedfedfed
groups:
- 603dab88-43a2-437a-b59f-0bee45d769c1
icon: Objects/host
interfaces: []
ipv4-address: 10.1.2.4
meta-info:
creation-time:
iso-8601: 2021-04-09T11:31-0400
posix: 1617982301463
creator: SVCFWPWorker
last-modifier: SVCFWPWorker
last-modify-time:
iso-8601: 2021-04-23T13:05-0400
posix: 1619197554087
lock: unlocked
validation-state: ok
name: gTest102
nat-settings:
auto-rule: false
read-only: false
tags: []
type: host
uid: 6bcfa0a5-da21-4a6e-8bde-3c5f486012e6
meta-info:
creation-time:
iso-8601: 2021-04-09T11:31-0400
posix: 1617982294818
creator: SVCFWPWorker
last-modifier: SVCFWPWorker
last-modify-time:
iso-8601: 2021-04-09T11:31-0400
posix: 1617982305162
lock: unlocked
validation-state: ok
name: gTest1A
read-only: false
tags: []
type: group
uid: 603dab88-43a2-437a-b59f-0bee45d769c1
I want the new list created, new_list_created.yml to look like this
list:
- comments: FWP - Testing this
ipv4-address: 10.1.2.3
name: gTest101
- comments: FWP - Applying this
ipv4-address: 10.1.2.4
name: gTest102