Refactor hardcoded strings to vars
Change-Id: I507ceca9fc5d819e900194d520df947b731631e6
diff --git a/playbooks/setup-openstack-storpool/pre.yaml b/playbooks/setup-openstack-storpool/pre.yaml
index 208623e..03a8547 100644
--- a/playbooks/setup-openstack-storpool/pre.yaml
+++ b/playbooks/setup-openstack-storpool/pre.yaml
@@ -232,7 +232,7 @@
- name: Load Required Information from Previous Stage
ansible.builtin.include_vars:
- file: "{{ hostvars.localhost.tmpdir }}/undercloud-client/home/ubuntu/ansivars.yaml"
+ file: "{{ hostvars.localhost.tmpdir }}/undercloud-client/{{ undercloud_client_node_homedir }}/ansivars.yaml"
when: storpool_connection == "iscsi"
@@ -270,7 +270,7 @@
- name: Provision StorPool Deployment Configuration
no_log: true
ansible.builtin.lineinfile:
- path: /home/ubuntu/.ssh/authorized_keys
+ path: "{{ storpool_node_homedir }}/.ssh/authorized_keys"
line: "{{ STORPOOL_DEPLOY_KEY_PUB['v'] }}"
insertafter: EOF
@@ -311,7 +311,7 @@
- name: Provision StorPool Deployment Configuration
no_log: true
ansible.builtin.lineinfile:
- path: /home/ubuntu/.ssh/authorized_keys
+ path: "{{ openstack_node_homedir }}/.ssh/authorized_keys"
line: "{{ STORPOOL_DEPLOY_KEY_PUB['v'] }}"
insertafter: EOF
@@ -323,7 +323,7 @@
tasks:
- name: Ensure StorPool Deployment Configuration Directory Exists
ansible.builtin.file:
- path: /home/ubuntu/.ssh
+ path: "{{ undercloud_client_node_homedir }}/.ssh"
state: directory
mode: '0700'
recurse: true
@@ -332,14 +332,14 @@
no_log: true
ansible.builtin.copy:
content: "{{ STORPOOL_DEPLOY_KEY['v'] }}"
- dest: /home/ubuntu/.ssh/id_rsa
+ dest: "{{ undercloud_client_node_homedir }}/.ssh/id_rsa"
mode: '0400'
- name: Provision StorPool Deployment Configuration 2
no_log: true
ansible.builtin.copy:
content: "{{ STORPOOL_DEPLOY_KEY_PUB['v'] }}"
- dest: /home/ubuntu/.ssh/id_rsa.pub
+ dest: "{{ undercloud_client_node_homedir }}/.ssh/id_rsa.pub"
- name: Provision StorPool Deployment Configuration 3
no_log: true
@@ -364,13 +364,13 @@
- name: Checkout StorPool Ansible
ansible.builtin.git:
repo: 'https://github.com/storpool/ansible'
- dest: /home/ubuntu/ansible
+ dest: "{{ storpool_ansible_dir }}"
- name: Download Required Ansible Roles
ansible.builtin.command:
argv: ["ansible-galaxy", "install", "-r", "roles/requirements.yml"]
args:
- chdir: "/home/ubuntu/ansible"
+ chdir: "{{ storpool_ansible_dir }}"
- name: Configure a Git Identity
ansible.builtin.command:
@@ -395,7 +395,7 @@
no_log: true
ansible.builtin.copy:
content: "{{ storpool_inventory }}"
- dest: /home/ubuntu/ansible/inventory.yaml
+ dest: "{{ storpool_ansible_dir }}/inventory.yaml"
- name: Install StorPool
block:
@@ -417,24 +417,24 @@
no_log: true
ansible.builtin.copy:
content: "{{ storpool_conf }}"
- dest: /home/ubuntu/ansible/storpool.conf
+ dest: "{{ storpool_ansible_dir }}/storpool.conf"
- name: Provision the StorPool Deployment
no_log: true
ansible.builtin.copy:
content: "{{ hostvars['localhost'].STORPOOL_DEPLOY.v }}"
- dest: /home/ubuntu/ansible/storpool-deploy.patch
+ dest: "{{ storpool_ansible_dir }}/storpool-deploy.patch"
- name: Provision the StorPool Deployment Info
no_log: true
ansible.builtin.copy:
content: "{{ storpool_deploy_info_conf }}"
- dest: /home/ubuntu/ansible/storpool_deploy_info.conf
+ dest: "{{ storpool_ansible_dir }}/storpool_deploy_info.conf"
- name: Populate ansible.cfg
ansible.builtin.lineinfile:
line: "{{ item }}"
- path: /home/ubuntu/ansible/ansible.cfg
+ path: "{{ storpool_ansible_dir }}/ansible.cfg"
insertafter: EOF
create: yes
loop:
@@ -445,20 +445,20 @@
ansible.builtin.command:
argv: ["git", "am", "storpool-deploy.patch"]
args:
- chdir: "/home/ubuntu/ansible"
+ chdir: "{{ storpool_ansible_dir }}"
- name: Deploy StorPool
ansible.builtin.command:
argv: ["ansible-playbook", "playbook.yml", "-i", "inventory.yaml", "--skip-tags", "perform-tests"]
args:
- chdir: "/home/ubuntu/ansible"
+ chdir: "{{ storpool_ansible_dir }}"
always:
- name: Deprovision the StorPool deployment info locally
no_log: true
ansible.builtin.file:
- path: /home/ubuntu/ansible/storpool_deploy_info.conf
+ path: "{{ storpool_ansible_dir }}/storpool_deploy_info.conf"
state: absent
- hosts: controller
diff --git a/playbooks/setup-openstack-storpool/vars.yaml b/playbooks/setup-openstack-storpool/vars.yaml
index bf810ba..6e37d99 100644
--- a/playbooks/setup-openstack-storpool/vars.yaml
+++ b/playbooks/setup-openstack-storpool/vars.yaml
@@ -3,12 +3,16 @@
storpool_node: "{{ hostvars['lab-sp-a1']['nodepool']['external_id'] }}"
storpool_node_ip: "{{ hostvars['lab-sp-a1']['nodepool']['interface_ip'] }}"
storpool_node_hostname: "{{ hostvars['lab-sp-a1']['ansible_hostname'] }}"
+storpool_node_homedir: " {{ hostvars['lab-sp-a1']['ansible_env']['home'] }}"
undercloud_client_node: "{{ hostvars['undercloud-client']['nodepool']['external_id'] }}"
+undercloud_client_node_homedir: " {{ hostvars['undercloud-client']['ansible_env']['home'] }}"
+storpool_ansible_dir: "{{ undercloud_client_node_homedir }}/ansible"
openstack_node: "{{ hostvars['controller']['nodepool']['external_id'] }}"
openstack_node_ip: "{{ hostvars['controller']['nodepool']['interface_ip'] }}"
openstack_node_hostname: "{{ hostvars['controller']['ansible_hostname'] }}"
+openstack_node_homedir: " {{ hostvars['controller']['ansible_env']['home'] }}"
storpool_volume: "{{ undercloud_client_node }}-storpool-volume"