116 lines
3.4 KiB
YAML
116 lines
3.4 KiB
YAML
---
|
|
# Copyright 2017, Rackspace US, Inc.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
# NOTE(cloudnull): At this time the nspawn implementation does not support suse.
|
|
# When we can use networkd on suse this should be revised.
|
|
- name: Check if os is suse
|
|
fail:
|
|
msg: >-
|
|
At this time the nspawn implementation does not support suse.
|
|
when:
|
|
- ansible_pkg_mgr == 'zypper'
|
|
|
|
- name: Pull systemd version
|
|
command: "systemctl --version"
|
|
changed_when: false
|
|
register: systemd_version
|
|
tags:
|
|
- skip_ansible_lint
|
|
|
|
- name: Set facts
|
|
set_fact:
|
|
nspawn_systemd_version: "{{ systemd_version.stdout_lines[0].split()[-1] }}"
|
|
|
|
- name: Gather variables for each operating system
|
|
include_vars: "{{ item }}"
|
|
with_first_found:
|
|
- "{{ hostvars[physical_host]['ansible_distribution'] | lower }}-{{ hostvars[physical_host]['ansible_distribution_version'] | lower }}.yml"
|
|
- "{{ hostvars[physical_host]['ansible_distribution'] | lower }}-{{ hostvars[physical_host]['ansible_distribution_major_version'] | lower }}.yml"
|
|
- "{{ hostvars[physical_host]['ansible_os_family'] | lower }}-{{ hostvars[physical_host]['ansible_distribution_major_version'] | lower }}.yml"
|
|
- "{{ hostvars[physical_host]['ansible_distribution'] | lower }}.yml"
|
|
- "{{ hostvars[physical_host]['ansible_os_family'] | lower }}.yml"
|
|
tags:
|
|
- always
|
|
|
|
- name: Prevent service from starting on install
|
|
copy:
|
|
content: |
|
|
#!/bin/bash
|
|
exit 101
|
|
dest: "/usr/sbin/policy-rc.d"
|
|
mode: "0755"
|
|
when:
|
|
- ansible_pkg_mgr == 'apt'
|
|
notify:
|
|
- Remove policy-rc
|
|
|
|
- name: Install distro packages
|
|
package:
|
|
pkg: "{{ nspawn_hosts_distro_packages }}"
|
|
state: "{{ nspawn_hosts_package_state }}"
|
|
register: install_packages
|
|
until: install_packages|success
|
|
retries: 5
|
|
delay: 2
|
|
notify:
|
|
- Disable host dnsmasq service
|
|
- Restart networkd
|
|
|
|
- name: Move nspawn-attach into place
|
|
copy:
|
|
src: nspawn-attach.sh
|
|
dest: /usr/local/bin/nspawn-attach
|
|
mode: '0755'
|
|
|
|
- name: Create networkd and nspawn directories
|
|
file:
|
|
path: "{{ item }}"
|
|
state: directory
|
|
with_items:
|
|
- /etc/systemd/nspawn
|
|
- /etc/systemd/network
|
|
- /etc/systemd/journald.conf.d
|
|
- /var/log/journal
|
|
notify:
|
|
- Create tmpfiles structure in journald
|
|
|
|
- name: Create journald tempfiles
|
|
template:
|
|
src: "systemd-journald-tmpfiles.j2"
|
|
dest: "/etc/tmpfiles.d/systemd-journald.conf"
|
|
notify:
|
|
- Create tmpfiles structure in journald
|
|
- Restart systemd-journald
|
|
|
|
- name: Create journald tempfiles
|
|
template:
|
|
src: "systemd-journald-nspawn_host.conf.j2"
|
|
dest: "/etc/systemd/journald.conf.d/systemd-journald-nspawn_host.conf"
|
|
notify:
|
|
- Create tmpfiles structure in journald
|
|
- Restart systemd-journald
|
|
|
|
- include: nspawn_cache_prestage.yml
|
|
tags:
|
|
- always
|
|
|
|
- include: nspawn_volume.yml
|
|
|
|
- include: nspawn_networking.yml
|
|
|
|
- include: nspawn_cache.yml
|
|
|
|
- include: nspawn_networking.yml
|