|
1 | 1 | --- |
2 | 2 |
|
3 | | - - name: Check for valid configuration of oracle_databases |
4 | | - no_log: true |
5 | | - assert: |
6 | | - that: |
7 | | - - item.1 is defined |
8 | | - with_subelements: |
9 | | - - "{{oracle_databases}}" |
10 | | - - rman_jobs |
11 | | - tags: |
12 | | - - assert |
13 | | - |
14 | 3 | - name: Default Destinations for RMAN |
15 | 4 | no_log: true |
16 | 5 | assert: |
|
23 | 12 | # autofs is configured in a special way to mount the shares with needed parameters |
24 | 13 | - name: configure autofs for RMAN |
25 | 14 | lineinfile: dest=/etc/auto.master regexp="^{{rmanautofsmount}} " line="{{rmanautofsmount}} /etc/auto.net --timeout=60 rw,hard,rsize=32768,wsize=32768,proto=tcp,nfsvers=3" |
26 | | - when: "rmanautofs|bool == true" |
| 15 | + when: rmanautofs |
27 | 16 | tags: autofs |
28 | 17 |
|
29 | 18 | - name: Create Mountpoint |
30 | 19 | file: dest={{rmanautofsmount}} state=directory |
31 | | - when: "rmanautofs|bool == true" |
| 20 | + when: rmanautofs |
32 | 21 | tags: autofs |
33 | 22 |
|
34 | 23 | - name: Restart autofs |
35 | 24 | service: name=autofs enabled=yes state=restarted |
36 | | - when: "rmanautofs|bool == true" |
| 25 | + when: rmanautofs |
37 | 26 | tags: autofs |
38 | 27 |
|
39 | 28 | - name: Create bin-Directory for rman_backup |
|
49 | 38 |
|
50 | 39 | # dummy with_together for item.0.db_name in default/main.yml |
51 | 40 | - name: Create Directory for rman-scripts |
52 | | - file: path={{oracle_admin_db}}/rman state=directory mode=0755 owner={{oracle_user}} |
| 41 | + file: path={{rman_script_dir}} state=directory mode=0755 owner={{oracle_user}} |
| 42 | + with_together: |
| 43 | + - "{{oracle_databases}}" |
| 44 | + - "" |
| 45 | + tags: |
| 46 | + - rmancopy |
| 47 | + |
| 48 | + # dummy with_together for item.0.db_name in default/main.yml |
| 49 | + - name: Create Directory for rman-logfiles |
| 50 | + file: path={{rman_log_dir}} state=directory mode=0755 owner={{oracle_user}} |
53 | 51 | with_together: |
54 | 52 | - "{{oracle_databases}}" |
55 | 53 | - "" |
|
61 | 59 | tags: |
62 | 60 | - rmancopy |
63 | 61 |
|
| 62 | + # rman_script_dir: {{oracle_admin_db}}/rman/ |
64 | 63 | - name: copy RMAN scipts |
65 | | - template: dest={{oracle_admin_db}}/rman/{{item.1.name}}.rman src={{item.1.name}}.rman.j2 backup=yes mode=644 owner={{oracle_user}} |
| 64 | + template: dest={{rman_script_dir}}/{{item.1.name}}.rman src={{item.1.name}}.rman.j2 backup=yes mode=644 owner={{oracle_user}} |
66 | 65 | with_subelements: |
67 | 66 | - "{{oracle_databases}}" |
68 | 67 | - rman_jobs |
| 68 | + - skip_missing: yes |
69 | 69 | tags: |
70 | 70 | - rmancopy |
71 | 71 |
|
| 72 | + - name: Create directory for TNS_ADMIN |
| 73 | + file: dest={{rman_tns_admin}} state=directory owner={{oracle_user}} |
| 74 | + with_items: |
| 75 | + - "{{oracle_databases}}" |
| 76 | + when: item.rman_tnsalias is defined |
| 77 | + tags: |
| 78 | + - tns |
| 79 | + |
| 80 | + - name: copy sqlnet.ora for wallet |
| 81 | + template: src=sqlnet.ora.j2 dest={{rman_tns_admin}}/sqlnet.ora owner={{oracle_user}} mode=644 |
| 82 | + with_items: |
| 83 | + - "{{oracle_databases}}" |
| 84 | + when: item.rman_tnsalias is defined |
| 85 | + tags: |
| 86 | + - tns |
| 87 | + |
| 88 | + - name: copy tnsnames.ora for catalog |
| 89 | + template: src=tnsnames.ora.j2 dest={{rman_tns_admin}}/tnsnames.ora owner={{oracle_user}} mode=644 backup=True |
| 90 | + with_items: |
| 91 | + - "{{oracle_databases}}" |
| 92 | + when: item.rman_tnsalias is defined |
| 93 | + tags: |
| 94 | + - tns |
| 95 | + |
| 96 | + - name: Wallet create |
| 97 | + shell: "test -d {{rman_wallet_loc}} || echo -e '{{rman_wallet_password}}\n{{rman_wallet_password}}' | {{oracle_home_db}}/bin/mkstore -create -nologo -wrl {{rman_wallet_loc}}" |
| 98 | + become: yes |
| 99 | + become_user: "{{ oracle_user }}" |
| 100 | + with_items: |
| 101 | + - "{{oracle_databases}}" |
| 102 | + when: item.rman_tnsalias is defined |
| 103 | + tags: |
| 104 | + - wallet |
| 105 | + |
| 106 | + # no_log => secure password against logfiles |
| 107 | + # ignore errors during createCredential when entry is existing |
| 108 | + - name: Wallet createCredential |
| 109 | + shell: "echo -e '{{rman_wallet_password}}' | {{oracle_home_db}}/bin/mkstore -wrl {{rman_wallet_loc}} -nologo -createCredential {{item.rman_tnsalias}} {{item.rman_user}} {{item.rman_password}}; exit 0" |
| 110 | + become: yes |
| 111 | + become_user: "{{ oracle_user }}" |
| 112 | + no_log: true |
| 113 | + with_items: |
| 114 | + - "{{oracle_databases}}" |
| 115 | + when: item.rman_tnsalias is defined and item.rman_user is defined and item.rman_password is defined |
| 116 | + tags: |
| 117 | + - wallet |
| 118 | + |
72 | 119 | # the following task is usefull for configuration of rman-parameters during setup of RMAN |
73 | 120 | # It's also possible to execute the 1st Level0-Backup after setup, but be aware to configure the RMAN before starting a backup |
74 | 121 | # The execution isn't done in async mode! |
75 | 122 | # The task is only execute once on master_node when GI is installed! |
| 123 | + # no catalog connection, because setting initial parameters with catalog takes much more time |
76 | 124 | - name: Execute RMAN-Script at playbook |
77 | | - shell: "{{oracle_base}}/bin/rman_backup.sh -a {{item.1.name}} -s {{item.0.oracle_db_name}} -r {{oracle_admin_db}}/rman -l {{oracle_admin_db}}/rman | tee -a {{rman_cron_logdir}}/rman_{{item.1.name}}.log" |
| 125 | + shell: "{{oracle_base}}/bin/rman_backup.sh -a {{item.1.name}} -s {{item.0.oracle_db_name}} -r {{rman_script_dir}} -l {{rman_log_dir}} | tee -a {{rman_cron_logdir}}/rman_{{item.1.name}}.log" |
78 | 126 | environment: |
79 | 127 | - PATH: /bin:/usr/bin |
80 | 128 | become: yes |
81 | 129 | become_user: "{{ oracle_user }}" |
82 | | - when: "'parameter' in item.1.name" |
83 | 130 | register: rmanexecimmediate |
84 | 131 | with_subelements: |
85 | 132 | - "{{oracle_databases}}" |
86 | 133 | - rman_jobs |
87 | | - when: item.1.immediate | default(false) == true and ((oracle_install_option_gi | default('SI') == 'CRS_CONFIG' and master_node) or oracle_install_option_gi != 'CRS_CONFIG') |
| 134 | + - skip_missing: yes |
| 135 | + when: master_node and item.1.immediate is defined and item.1.immediate |
88 | 136 | tags: |
89 | 137 | - rmanexecute |
90 | 138 |
|
91 | | - - debug: msg={{item.results[0].stdout_lines}} |
| 139 | +# - debug: msg={{item.results[0].stdout_lines | default("")}} |
| 140 | + - debug: msg={{item.results.stdout_lines | default("")}} |
92 | 141 | with_items: |
93 | 142 | - "{{rmanexecimmediate}}" |
| 143 | + when: rmanexecimmediate is defined |
94 | 144 | tags: |
95 | 145 | - rmanexecute |
96 | 146 |
|
| 147 | + - name: Add Environment variables to /ec/cron.d |
| 148 | + cron: |
| 149 | + cron_file: "{{rman_cronfile}}" |
| 150 | + user: "{{oracle_user}}" |
| 151 | + env: yes |
| 152 | + name: "{{ item.name }}" |
| 153 | + value: "{{ item.value }}" |
| 154 | + with_items: |
| 155 | + - { name: RMANLOGDIR , value: '{{ rman_log_dir }}' } |
| 156 | + - { name: RMANSCRIPTDIR , value: '{{ rman_script_dir }}' } |
| 157 | + - { name: RMANTNS_ADMIN , value: '{{ rman_tns_admin }}' } |
| 158 | + tags: |
| 159 | + - rmancron |
| 160 | + |
97 | 161 | - name: Create crontab entries for RMAN Backup |
98 | 162 | cron: |
99 | 163 | name: rman_backup_{{item.0.oracle_db_name}}_{{item.1.name}} |
|
104 | 168 | weekday: "{{item.1.weekday}}" |
105 | 169 | hour: "{{item.1.hour}}" |
106 | 170 | minute: "{{item.1.minute}}" |
107 | | - job: "{{oracle_base}}/bin/rman_backup.sh -a {{item.1.name}} -s {{item.0.oracle_db_name}} -r {{oracle_admin_db}}/rman -l {{oracle_admin_db}}/rman {{rman_service_param}} >> {{rman_cron_logdir}}/rman_{{item.1.name}}.log 2>&1" |
| 171 | + job: "{{ check_mk_mkjob }}{{oracle_base}}/bin/rman_backup.sh -a {{item.1.name}} -s {{item.0.oracle_db_name}} {{rman_service_param}} {{rman_catalog_param}} {{rmanbackuplogdir}} {{rmanbackupscriptdir}}>> {{rman_cron_logdir}}/rman_{{item.0.oracle_db_name}}_{{item.1.name}}.log 2>&1" |
108 | 172 | with_subelements: |
109 | 173 | - "{{oracle_databases}}" |
110 | 174 | - rman_jobs |
| 175 | + - skip_missing: yes |
111 | 176 | when: |
112 | 177 | - item.1 is defined |
113 | 178 | - item.1.disabled is defined |
|
116 | 181 | - item.1.hour is defined |
117 | 182 | - item.1.minute is defined |
118 | 183 | - item.1.name is defined |
119 | | - - item.0.oracle_install_option_gi | default('SI') != ('CRS_CONFIG') |
120 | 184 | tags: |
121 | 185 | - rmancron |
| 186 | + |
| 187 | + - name: Create directory for mk-job |
| 188 | + file: dest=/var/lib/check_mk_agent/job/{{oracle_user}} state=directory owner={{oracle_user}} |
| 189 | + when: rman_cron_mkjob |
| 190 | + tags: rmancron |
| 191 | + |
0 commit comments