Open rohan-zos-ansible opened 2 months ago
I am using ZOS CORE version 1.8.0
Hi @rohan-zos-ansible I work with your case and if you're using the default markers as I can see for your playbooks using
- name: Remove some libraries from Scripts in INI file
zos_blockinfile:
src: "{{ tmp_ds }}"
state: absent
ignore_errors: True
will work on you.
I try the playbook:
tasks:
- name: Create a sequential data set if it does not exist
zos_data_set:
name: "{{ tmp_ds }}"
type: seq
state: present
- name: Ensure
zos_lineinfile:
src: "{{ tmp_ds }}"
insertbefore: BOF
line: "script"
- name: Write on it
zos_blockinfile:
src: "{{ tmp_ds }}"
insertafter: EOF
block: |
UTIDSN(ZZZDBU.V51QA.SMPE.DBUSCRL +
ZZZBRI.QAV51.BRISCRL +
ZZZCDBU.V51QA.SMPE.DBUSCRS +
ZZZCBRI.QAV51.BRISCRS) +
SYSOUT(*) TRACE(Y) TRACEOUT(*)
- name: Remove some libraries from Scripts in INI file
zos_blockinfile:
src: "{{ tmp_ds }}"
state: absent
ignore_errors: True
- name: "dcat {{ tmp_ds }}"
ansible.builtin.shell:
cmd: "dcat {{ tmp_ds }}"
register: dcat
- name: "Result of dcat"
debug:
msg:
- "{{ dcat }}"
And got the next result:
Thank you so much @AndreMarcel99. It worked. How if i want to remove a block between BEGIN and END. I may not be able to use # but i could use * since # may not be allowed in my file as comment or marker. But, I may be able to use #.
SCRIPT +
* BEGIN ANSIBLE MANAGED BLOCK
UTIDSN(ZZZDBU.V51QA.SMPE.DBUSCRL +
ZZZBRI.QAV51.BRISCRL +
ZZZCDBU.V51QA.SMPE.DBUSCRS +
ZZZCBRI.QAV51.BRISCRS) +
SYSOUT(*) TRACE(Y) TRACEOUT(*)
* END ANSIBLE MANAGED BLOCK
@rohan-zos-ansible Still work, in these case I recommend
- name: Write on it
zos_blockinfile:
src: "{{ tmp_ds }}"
marker: "* {mark} ANSIBLE MANAGED BLOCK"
insertafter: EOF
block: |
UTIDSN(ZZZDBU.V51QA.SMPE.DBUSCRL +
ZZZBRI.QAV51.BRISCRL +
ZZZCDBU.V51QA.SMPE.DBUSCRS +
ZZZCBRI.QAV51.BRISCRS) +
SYSOUT(*) TRACE(Y) TRACEOUT(*)
- name: Remove some libraries from Scripts in INI file
zos_blockinfile:
marker: "* {mark} ANSIBLE MANAGED BLOCK"
src: "{{ tmp_ds }}"
state: absent
ignore_errors: True
Same playbook:
I check and try some cases and for the version of core you're using and I don't recommend to change the values of marker_begin or marker_end (Defaults are BEGIN and END respectively) when doing an insert.
I want to remove a block between # BEGIN and # END from a PDS member with the help of blockinfile module.
Code:
Not sure what mistake i am doing. If anyone has any knowledge on this, please let me know.
Thank you, Rohan
_Originally posted by @rohan-zos-ansible in https://github.com/ansible-collections/ibm_zos_core/discussions/1667_