Skip to content

Instantly share code, notes, and snippets.

@nrb
Last active May 17, 2017 02:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nrb/9240d6759f080efc218460aab9ae2cdb to your computer and use it in GitHub Desktop.
Save nrb/9240d6759f080efc218460aab9ae2cdb to your computer and use it in GitHub Desktop.
---
- name: Archive OpenStack API containers
# All opentack api containers, nothing "stateful" right now
# TODO: This hosts string is wrong; rabbit and utility containers were included. Use https://review.openstack.org/#/c/464703/ instead
# GOAL: Provide a way to roll through API containers, then do rabbitmq and mariadb in separate playbooks. Get them to gating team,
# then transition work for integrating artifacts to someone else
hosts: "all_containers:!rabbitmq_container:!galera_container:!repo_container:!memcached_container"
gather_facts: true
user: root
# Use 2 at a time so we don't accidentally get all 3 nodes for a service at once.
serial: 2
tasks:
- name: Archive and delete container
lxc_container:
name: "{{ inventory_hostname }}"
archive: true
archive_path: /opt/archives
state: absent
delegate_to: "{{ physical_host }}"
# Can't unarchive to a non-existent directory
- name: Create lxc directory
file:
name: "/var/lib/lxc/{{ inventory_hostname }}"
state: directory
delegate_to: "{{ physical_host }}"
- name: Restore container filesystem
unarchive:
src: "/opt/archives/{{ inventory_hostname }}.tar.tgz"
dest: "/var/lib/lxc/{{ inventory_hostname }}"
copy: no
delegate_to: "{{ physical_host }}"
- name: Restart container
lxc_container:
name: "{{ inventory_hostname }}"
state: started
delegate_to: "{{ physical_host }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment