Commit f47a310b authored by nanahira's avatar nanahira

add migrate script

parent c7967605
Pipeline #984 passed with stages
in 3 minutes and 18 seconds
---
- hosts: dns-in-docker
tasks:
- name: read dnsmasq.conf
become: true
shell: cat /etc/dnsmasq.conf || true
register: dnsmasq_conf_result
- name: read dnsmasq.d/dhcp.conf
become: true
shell: cat /etc/dnsmasq.d/dhcp.conf || true
register: dnsmasq_dhcp_result
- name: read old docker-compose file
become: '{{become_in_rsync}}'
shell: 'cat {{ansible_user_dir}}/router/docker-compose.yml || true'
register: docker_compose_result
- name: make a backup
shell: 'cp -rf {{ansible_user_dir}}/router {{ansible_user_dir}}/router-backup'
- name: dnsmasq.conf
become: true
copy:
content: '{{ dnsmasq_conf_result.stdout }}'
dest: '{{ansible_user_dir}}/router/dnsmasq.conf'
owner: '{{ ansible_user_id }}'
group: '{{ ansible_user_id }}'
- name: copy dnsmasq.d here
become: true
shell: 'cp -rf /etc/dnsmasq.d {{ansible_user_dir}}/router/dnsmasq.d || true'
- name: dnsmasq.d permission
become: true
file:
path: '{{ansible_user_dir}}/router/dnsmasq.d'
state: directory
recurse: true
owner: '{{ ansible_user_id }}'
group: '{{ ansible_user_id }}'
- name: remove libvirt-daemon
become: true
file:
path: '{{ansible_user_dir}}/router/dnsmasq.d/libvirt-daemon'
state: absent
- name: docker-compose file
become: true
copy:
content: |
{{docker_compose_result.stdout}}
dnsmasq:
restart: always
image: git-registry.mycard.moe/nanahira/dnsmasq:latest
network_mode: host
cap_add:
- NET_ADMIN
volumes:
- './dnsmasq.conf:/etc/dnsmasq.conf:ro'
- './dnsmasq.d:/etc/dnsmasq.d:ro'
- '/var/lib/misc:/var/lib/misc'
dest: '{{ansible_user_dir}}/router/docker-compose.yml'
owner: '{{ ansible_user_id }}'
group: '{{ ansible_user_id }}'
- name: pull image
become: true
docker_image:
name: git-registry.mycard.moe/nanahira/dnsmasq:latest
source: pull
- name: disable dnsmasq systemd
become: true
systemd:
name: dnsmasq
state: stopped
enabled:
- name: docker-compose up -d
docker_compose:
project_src: '{{ansible_user_dir}}/router'
services:
- dnsmasq
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment