-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclish_script_build.yml
More file actions
65 lines (56 loc) · 1.98 KB
/
clish_script_build.yml
File metadata and controls
65 lines (56 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
---
- debug:
msg:
- "{{ inv_host }} - {{ inventory_hostname }}"
- "{{ config_dir }} / {{ config_file }}"
- "{{ sys['vsx_host'] |default('no vsx') }}"
- "keep_script: {{ keep_script |default(false) |bool }}"
- "save_output: {{ save_output |default(false) |bool }}"
- "show_output: {{ show_output |default(true) |bool }}"
when: debug |default(false) |bool
- name: Create directory locally
ansible.builtin.file:
path: "{{ config_dir }}"
state: directory
mode: '0755'
run_once: true
delegate_to: localhost
- name: Generate CLISH script
ansible.builtin.template:
src: clish_cmd.j2
dest: "{{ config_dir }}/{{ config_file }}"
lstrip_blocks: true
delegate_to: localhost
vars:
clish_command: "{% if sys.vs_id is defined and clish_cmd == 'show configuration' %}{{ vs_clish_config_cmds }}{% else %}{{ clish_cmd }}{% endif %}"
- name: "Create {{ config_dir }} on {{ inventory_hostname }}"
include_tasks: run_script.yml
vars:
description: 'Create CLISH config directory'
script: "mkdir -p /home/admin/{{ config_dir }}"
wait_for_task: true
- name: Copy CLISH script
check_point.gaia.cp_gaia_put_file:
file_name: "/home/admin/{{ config_dir }}/{{ config_file }}"
text_content: "{{ lookup('file', [ config_dir, config_file ] |join('/') ) }}\n"
override: true
- include_tasks: apply_clish_script.yml
- include_tasks: save_output.yml
when:
- script_res.run_script.tasks[0]['task-details'][0]['return-value'] == 0
- block:
- name: Remove CLISH script
ansible.builtin.file:
path: "{{ config_dir }}/{{ config_file }}"
state: absent
delegate_to: localhost
- name: Remove CLISH script from gateway
include_tasks: run_script.yml
vars:
description: 'Create CLISH config directory'
script: "rm /home/admin/{{ config_dir }}/{{ config_file }}"
wait_for_task: true
when:
- not (keep_script |default(false) |bool)
- ansible_loop.last |default(true)
...