infra/provision.yml

71 lines
1.9 KiB
YAML
Raw Normal View History

2018-10-02 09:12:23 +03:00
---
- name: check input parameters
hosts: localhost
gather_facts: false
tags: always
tasks:
- fail: msg="env_name should be set"
when: env_name is not defined
- fail: msg="stack_name should be set"
when: stack_name is not defined
- name: provisioning PVE nodes
hosts: localhost
gather_facts: false
roles:
- {role: prepare-config, tags: [ ]}
- {role: pve, tags: [ ]}
- {role: lxc, tags: [ ]}
- {role: inventory, bootstrap: yes, tags: [ ]}
tags: [ provision ]
2022-03-09 03:53:23 +03:00
#- name: Wait for VMs to go up
# hosts: localhost
# gather_facts: false
# tasks:
# - pause:
# minutes: 2
# when: destroy_all is not defined or not destroy_all
2019-12-06 12:06:33 +03:00
2018-10-02 09:12:23 +03:00
- name: prepare nodes
hosts: stack
gather_facts: false
2018-11-21 09:14:52 +03:00
# cannot use free strategy due usage of add_host after
2018-11-01 22:39:50 +03:00
# NICs reconfiguration
#strategy: free
2018-10-02 09:12:23 +03:00
pre_tasks:
- meta: end_play
2018-11-07 15:49:51 +03:00
when: destroy_all is defined and destroy_all|bool
2018-10-02 09:12:23 +03:00
- name: gather facts
setup:
when: destroy_all is not defined or not destroy_all
roles:
- {role: prepare-config, tags: [ ]}
- {role: common, tags: [ ]}
tags: [ prepare ]
2018-11-01 21:59:05 +03:00
- name: put ssh host keys to all nodes
hosts: stack
gather_facts: false
strategy: free
2018-11-07 15:49:51 +03:00
pre_tasks:
- meta: end_play
when: destroy_all is defined and destroy_all|bool
2018-11-01 21:59:05 +03:00
tasks:
- name: put keys to known hosts
copy:
src: ".tmp/{{ stack_name }}.known_hosts"
2018-11-01 22:39:50 +03:00
dest: "/etc/openssh/ssh_known_hosts"
2018-11-01 21:59:05 +03:00
owner: root
group: root
mode: 0644
2022-03-09 08:01:02 +03:00
#- name: register nodes in /etc/hosts
# lineinfile:
# path: /etc/hosts
# regexp: ".*{{ item }}$"
# line: "{{ hostvars[item].ansible_default_ipv4.address }} {{ item }}"
# state: present
# when: hostvars[item].ansible_default_ipv4.address is defined
# with_items: "{{ play_hosts }}"
2018-11-01 21:59:05 +03:00
tags: [ prepare ]