Skip to content

Commit

Permalink
chore: Changed dir structure for role boot from ftp
Browse files Browse the repository at this point in the history
Signed-off-by: Klaus Smolin <[email protected]>
  • Loading branch information
smolin-de committed Jul 25, 2024
1 parent d58ca09 commit 003ab3d
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 47 deletions.
46 changes: 46 additions & 0 deletions roles/boot_lpar_from_ftp/tasks/classic_mode.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---

- name: Boot LPAR node using boot from ftp function
block:
- name: Define local variables
ansible.builtin.set_fact:
_hmc_load_from_ftp_file_path: "{{ parm_lpar_prm_files[idx] }}"

- name: Create temporary config file
ansible.builtin.tempfile:
state: file
suffix: temp
register: _config_yaml_tempfile

- name: Create HMC load from ftp config file from template
ansible.builtin.template:
src: "hmc_load_from_ftp.j2"
dest: "{{ _config_yaml_tempfile.path }}"
mode: u=rw,g=r,o=r
force: true

- name: Execute HMC load from ftp function
ansible.builtin.shell: |
set -e
{{ role_path }}/files/hmc_load_from_ftp.py "{{ _config_yaml_tempfile.path }}"
# Delete tempfile
rm -f "{{ _config_yaml_tempfile.path }}"
register: cmd_output

- name: Execute HMC load from ftp function - command output
ansible.builtin.debug:
var: cmd_output

rescue:
- name: Cleanup on error
block:
- name: Cleanup on error
ansible.builtin.shell: |
# cat "{{ _config_yaml_tempfile.path }}"
# Delete tempfile
rm -f "{{ _config_yaml_tempfile.path }}"
register: cmd_output

- name: Cleanup on error - command output
ansible.builtin.debug:
var: cmd_output
Empty file.
59 changes: 12 additions & 47 deletions roles/boot_lpar_from_ftp/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -1,55 +1,20 @@
---

- name: Check role/task parameters
ansible.builtin.fail:
msg: "Error: loop control variable 'idx' is not defined"
when: idx is not defined

- name: Boot LPAR node using boot from ftp function
block:
- name: Include LPAR host variablese
ansible.builtin.include_vars:
file: "{{ inventory_dir }}/host_vars/{{ parm_lpar_names[idx] }}.yaml"
name: _node

- name: Define local variables
ansible.builtin.set_fact:
_hmc_load_from_ftp_file_path: "{{ parm_lpar_prm_files[idx] }}"

- name: Create temporary config file
ansible.builtin.tempfile:
state: file
suffix: temp
register: _config_yaml_tempfile

- name: Create HMC load from ftp config file from template
ansible.builtin.template:
src: "hmc_load_from_ftp.j2"
dest: "{{ _config_yaml_tempfile.path }}"
mode: u=rw,g=r,o=r
force: true

- name: Execute HMC load from ftp function
ansible.builtin.shell: |
set -e
{{ role_path }}/files/hmc_load_from_ftp.py "{{ _config_yaml_tempfile.path }}"
# Delete tempfile
rm -f "{{ _config_yaml_tempfile.path }}"
register: cmd_output

- name: Execute HMC load from ftp function - command output
ansible.builtin.debug:
var: cmd_output
- name: Include LPAR host variablese
ansible.builtin.include_vars:
file: "{{ inventory_dir }}/host_vars/{{ parm_lpar_names[idx] }}.yaml"
name: _node

rescue:
- name: Cleanup on error
block:
- name: Cleanup on error
ansible.builtin.shell: |
# cat "{{ _config_yaml_tempfile.path }}"
# Delete tempfile
rm -f "{{ _config_yaml_tempfile.path }}"
register: cmd_output
- name: Lood classic mode task
when: 1
ansible.builtin.include_tasks: "classic_mode.yaml"

- name: Cleanup on error - command output
ansible.builtin.debug:
var: cmd_output
- name: Lood dpm mode task
when: 0
# _node.cpc_dpm_mode is defined and _node.cpc_dpm_mode
ansible.builtin.include_tasks: "dpm_mode.yaml"

0 comments on commit 003ab3d

Please sign in to comment.