Avoid re-stacking when not necessary
Also adds a swap file of 8GB Change-Id: I50b7dcb5ca40c9840ae086006c9d868637d3b5d0
This commit is contained in:
parent
d0d2c1c362
commit
9108be7e83
5
Vagrantfile
vendored
5
Vagrantfile
vendored
@ -32,6 +32,9 @@ PROJECTS_DIR = File.dirname(ENV.fetch('PROJECTS_DIR', VAGRANTFILE_DIR))
|
|||||||
|
|
||||||
GIT_BASE = ENV.fetch('GIT_BASE', 'https://opendev.org')
|
GIT_BASE = ENV.fetch('GIT_BASE', 'https://opendev.org')
|
||||||
|
|
||||||
|
TOX_ENVLIST = ENV.fetch('TOX_ENVLIST', '')
|
||||||
|
TOX_EXTRA_ARGS = ENV.fetch('TOX_EXTRA_ARGS', '--notest')
|
||||||
|
|
||||||
# Local project directories to be copied
|
# Local project directories to be copied
|
||||||
DEVSTACK_PROJECTS = {
|
DEVSTACK_PROJECTS = {
|
||||||
# Local directory from where look for devstack project files
|
# Local directory from where look for devstack project files
|
||||||
@ -120,6 +123,8 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
|||||||
ansible.playbook = PROVISION_PLAYBOOK
|
ansible.playbook = PROVISION_PLAYBOOK
|
||||||
ansible.extra_vars = ansible.extra_vars = {
|
ansible.extra_vars = ansible.extra_vars = {
|
||||||
'devstack_projects' => DEVSTACK_PROJECTS,
|
'devstack_projects' => DEVSTACK_PROJECTS,
|
||||||
|
'tox_envlist' => TOX_ENVLIST,
|
||||||
|
'tox_extra_args' => TOX_EXTRA_ARGS,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
vars:
|
vars:
|
||||||
resolv_conf_file: /etc/resolv.conf
|
resolv_conf_file: /etc/resolv.conf
|
||||||
dest_dir: /opt/stack
|
dest_dir: /opt/stack
|
||||||
tox_extra_args: --notest
|
|
||||||
|
|
||||||
pre_tasks:
|
pre_tasks:
|
||||||
|
|
||||||
|
5
roles/devstack-tobiko-deploy/defaults/main.yaml
Normal file
5
roles/devstack-tobiko-deploy/defaults/main.yaml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
force_restack: false
|
||||||
|
stack_succeeded_file: '{{ devstack_dir }}/SUCCEEDED'
|
||||||
|
swap_file_size: 8192
|
27
roles/devstack-tobiko-deploy/tasks/add-swap-file.yaml
Normal file
27
roles/devstack-tobiko-deploy/tasks/add-swap-file.yaml
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- name: "Add a swap file of {{ swap_file_size }} MBytes"
|
||||||
|
become: true
|
||||||
|
become_user: root
|
||||||
|
shell:
|
||||||
|
cmd: |
|
||||||
|
# does the swap file already exist?
|
||||||
|
if grep -q "swapfile" /etc/fstab; then
|
||||||
|
echo 'swapfile found. No changes made.'
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo 'swapfile not found. Adding swapfile...'
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
fallocate -l '{{ swap_file_size }}M' /swapfile
|
||||||
|
chmod 600 /swapfile
|
||||||
|
mkswap /swapfile
|
||||||
|
swapon /swapfile
|
||||||
|
echo '/swapfile none swap defaults 0 0' >> /etc/fstab
|
||||||
|
echo 'swapfile added.'
|
||||||
|
exit 0
|
||||||
|
|
||||||
|
register: add_swap_file
|
||||||
|
changed_when: >-
|
||||||
|
'swapfile added' in add_swap_file.stdout
|
38
roles/devstack-tobiko-deploy/tasks/check_restack.yaml
Normal file
38
roles/devstack-tobiko-deploy/tasks/check_restack.yaml
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- when: not (force_restack | bool)
|
||||||
|
block:
|
||||||
|
- name: check file '{{ stack_succeeded_file }}' exists
|
||||||
|
stat:
|
||||||
|
path: '{{ stack_succeeded_file }}'
|
||||||
|
register: check_devstack_succeeded_file_exists
|
||||||
|
failed_when: no
|
||||||
|
|
||||||
|
- debug: var=check_devstack_succeeded_file_exists
|
||||||
|
|
||||||
|
- set_fact:
|
||||||
|
force_restack: >-
|
||||||
|
{{ not check_devstack_succeeded_file_exists.stat.exists |
|
||||||
|
default(true) |
|
||||||
|
bool }}
|
||||||
|
|
||||||
|
- debug: var=force_restack
|
||||||
|
|
||||||
|
|
||||||
|
- when: force_restack | bool
|
||||||
|
block:
|
||||||
|
- name: check file '{{ devstack_dir }}/local.conf' exists
|
||||||
|
stat:
|
||||||
|
path: '{{ devstack_dir }}/local.conf'
|
||||||
|
register: check_devstack_local_conf_file_exists
|
||||||
|
failed_when: no
|
||||||
|
|
||||||
|
- debug: var=check_devstack_local_conf_file_exists
|
||||||
|
|
||||||
|
- set_fact:
|
||||||
|
force_restack: >-
|
||||||
|
{{ check_devstack_local_conf_file_exists.stat.exists |
|
||||||
|
default(false) |
|
||||||
|
bool }}
|
||||||
|
|
||||||
|
- debug: var=force_restack
|
@ -9,7 +9,6 @@
|
|||||||
mode: '0755'
|
mode: '0755'
|
||||||
owner: stack
|
owner: stack
|
||||||
group: stack
|
group: stack
|
||||||
recurse: yes
|
|
||||||
when: >-
|
when: >-
|
||||||
( project_src_dir | length) > 0 or
|
( project_src_dir | length) > 0 or
|
||||||
( project_git_repo | length) > 0
|
( project_git_repo | length) > 0
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
|
- include_tasks: add-swap-file.yaml
|
||||||
- include_tasks: install-bindeps.yaml
|
- include_tasks: install-bindeps.yaml
|
||||||
- include_tasks: ensure-stack-user.yaml
|
- include_tasks: ensure-stack-user.yaml
|
||||||
- include_tasks: run-unstack.yaml
|
- include_tasks: run-unstack.yaml
|
||||||
|
@ -1,17 +1,24 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
|
- include_tasks: check_restack.yaml
|
||||||
|
|
||||||
- name: run stack.sh
|
- name: run stack.sh
|
||||||
become: true
|
become: true
|
||||||
become_user: stack
|
become_user: stack
|
||||||
shell:
|
shell:
|
||||||
cmd: |
|
cmd: |
|
||||||
sudo su -l stack -c "cd '{{ devstack_dir }}' && ./stack.sh" 2>&1
|
sudo su -l stack -c "
|
||||||
|
cd '{{ devstack_dir }}' &&
|
||||||
|
./stack.sh &&
|
||||||
|
touch '{{ stack_succeeded_file }}'
|
||||||
|
" 2>&1
|
||||||
rc=$?
|
rc=$?
|
||||||
echo "*** FINISHED ***"
|
echo "*** FINISHED ***"
|
||||||
exit $rc
|
exit $rc
|
||||||
chdir: '{{ devstack_dir }}'
|
chdir: '{{ devstack_dir }}'
|
||||||
register: run_stack
|
register: run_stack
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
|
when: force_restack | bool
|
||||||
|
|
||||||
|
|
||||||
- name: show stack.sh output
|
- name: show stack.sh output
|
||||||
|
@ -1,25 +1,23 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
- name: check '{{ devstack_dir }}/local.conf' exists
|
- include_tasks: check_restack.yaml
|
||||||
stat:
|
|
||||||
path: '{{ devstack_dir }}/local.conf'
|
|
||||||
register: check_devstack_local_conf_file_exists
|
|
||||||
failed_when: no
|
|
||||||
|
|
||||||
|
|
||||||
- name: run unstack.sh
|
- name: run unstack.sh
|
||||||
become: yes
|
become: yes
|
||||||
become_user: stack
|
become_user: stack
|
||||||
shell:
|
shell:
|
||||||
cmd: |
|
cmd: |
|
||||||
sudo su -l stack -c "cd '{{ devstack_dir }}' && ./unstack.sh" 2>&1
|
sudo su -l stack -c "
|
||||||
|
rm -f '{{ stack_succeeded_file }}';
|
||||||
|
cd '{{ devstack_dir }}' &&
|
||||||
|
./unstack.sh
|
||||||
|
" 2>&1
|
||||||
rc=$?
|
rc=$?
|
||||||
echo "*** FINISHED ***"
|
echo "*** FINISHED ***"
|
||||||
exit $rc
|
exit $rc
|
||||||
register: run_unstack
|
register: run_unstack
|
||||||
ignore_errors: yes
|
ignore_errors: yes
|
||||||
when:
|
when: force_restack | bool
|
||||||
check_devstack_local_conf_file_exists.stat.exists | default(False)
|
|
||||||
|
|
||||||
|
|
||||||
- debug: var=run_unstack.stdout_lines
|
- debug: var=run_unstack.stdout_lines
|
||||||
|
@ -1,6 +1,13 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
- name: 'Run test cases: {{ tox_command_line }}'
|
- set_fact:
|
||||||
|
tox_command_line: "{{ tox_command_line | replace('\n', '') }}"
|
||||||
|
|
||||||
|
|
||||||
|
- debug: var=tox_command_line
|
||||||
|
|
||||||
|
|
||||||
|
- name: "Run test cases: {{ tox_command_line }}"
|
||||||
become: true
|
become: true
|
||||||
become_user: stack
|
become_user: stack
|
||||||
shell:
|
shell:
|
||||||
|
Loading…
Reference in New Issue
Block a user