AdvancedLinuxAdmin/ansible/playbooks/role-infra-host.yml
Neil Hanlon 9c87fb8c87
add and update ansible playbooks for infra
- [openstack_user_config]: remove NFS in favor of (properly isntalled)
  iscsi
- [openstack_user_config]: remove extraneous config in favor of shorter
  version
- [storage] install and enable targetd (target.service)
- [ansible] only run 'infra' tags on the first infra host - never on an
  AIO
- [ansible] change roles to use the ``host`` extra var to configure
  where to run to mitigate accidents
- [ansible] add aio steps to infra playbook
- [ansible] add storage host playbook to configure volumes and iscsi
- [ansible] aio: configure volume groups
2022-01-10 13:20:05 -05:00

127 lines
3.4 KiB
YAML

---
- name: Bootstrap
hosts: "{{ host }}"
become: true
handlers:
- import_tasks: handlers/main.yml
pre_tasks:
- name: Check if ansible cannot be run here
stat:
path: /etc/no-ansible
register: no_ansible
- name: Verify if we can run ansible
assert:
that:
- "not no_ansible.stat.exists"
success_msg: "We are able to run on this node"
fail_msg: "/etc/no-ansible exists - skipping run on this node"
tasks:
- name: Loading Variables from OS Common
import_tasks: tasks/common_vars.yml
- name: Bootstrap ansible
become: true
shell: scripts/bootstrap-ansible.sh
args:
chdir: /opt/openstack-ansible/
creates: /etc/ansible/
tags:
- bootstrap
- name: Fix roles
become: true
ansible.builtin.shell:
cmd: grep -ril 'openstack.config_template.' /etc/ansible/roles/ | xargs sed -i.bak 's,openstack.config_template.,,g'
tags:
- temporary
- ansible
- bootstrap
- name: Deploy and setup configuration
when: not aio_install | default('true') # bootstrap-AIO script instead does these things.
block:
- name: Copy template to etc
ansible.builtin.copy:
remote_src: yes
src: /opt/openstack-ansible/etc/openstack_deploy/
dest: /etc/openstack_deploy/
directory_mode: yes
force: no
- name: Copy distributed openstack configs
ansible.builtin.copy:
src: "files/{{ item }}.yml"
dest: /etc/openstack_deploy/
mode: '0644'
with_items:
- openstack_user_config
- name: Create secrets
become: true
ansible.builtin.shell:
cmd: /opt/openstack-ansible/scripts/pw-token-gen.py --file /etc/openstack_deploy/user_secrets.yml
tags: secrets
args:
creates: /etc/openstack_deploy/user_secrets.yml.tar
- name: "[AIO] Deploy and setup configuration / bootstrap"
when: aio_install | default('false')
block:
- name: Debug - Running AIO bootstrap
debug:
var: aio_install
- name: Run bootstrap ansible with included args
ansible.builtin.shell: scripts/bootstrap-aio.sh
become: true
args:
chdir: /opt/openstack-ansible/
creates: /etc/openstack_deploy/
tags:
- bootstrap
- aio
- name: Create volume group for cinder
lvg:
pv_options: --metadatasize=2048
pvs: "{{ cinder_pv_device | default('/dev/vdb') }}"
vg: cinder-volumes
- name: Copy common openstack configs
ansible.builtin.copy:
src: "files/{{ item }}.yml"
dest: /etc/openstack_deploy/
mode: '0644'
with_items:
- user_lxc
- user_galera
- name: Check playbooks
tags: syntax
become: true
ansible.builtin.shell:
cmd: "openstack-ansible --syntax-check setup-{{ item }}.yml"
args:
chdir: /opt/openstack-ansible/playbooks/
loop:
- hosts
- infrastructure
- openstack
register: playbooks_res
post_tasks:
- name: Touching run file that ansible has ran here
file:
path: /var/log/ansible.run
state: touch
mode: '0644'
owner: root
group: root
...