From edf447b86f291118443987ab67de35b99e9b2d38 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Wed, 24 Jul 2019 01:12:57 +0300 Subject: [PATCH] Feat(init-system2): Setup ~root by copying files from ~phd --- playbooks/debian/init-system2.yml | 1 + playbooks/debian/roles/root/README.txt | 1 + playbooks/debian/roles/root/tasks/main.yml | 5 ++ playbooks/debian/roles/root/tasks/mc.yml | 59 +++++++++++++++++++ playbooks/debian/roles/root/tasks/root.yml | 67 ++++++++++++++++++++++ 5 files changed, 133 insertions(+) create mode 100644 playbooks/debian/roles/root/README.txt create mode 100644 playbooks/debian/roles/root/tasks/main.yml create mode 100644 playbooks/debian/roles/root/tasks/mc.yml create mode 100644 playbooks/debian/roles/root/tasks/root.yml diff --git a/playbooks/debian/init-system2.yml b/playbooks/debian/init-system2.yml index 0efdf4a..335299e 100644 --- a/playbooks/debian/init-system2.yml +++ b/playbooks/debian/init-system2.yml @@ -3,3 +3,4 @@ gather_facts: false roles: - remove-systemd + - root diff --git a/playbooks/debian/roles/root/README.txt b/playbooks/debian/roles/root/README.txt new file mode 100644 index 0000000..e970e2a --- /dev/null +++ b/playbooks/debian/roles/root/README.txt @@ -0,0 +1 @@ +Init new Debian system: setup ~root by copying files from ~phd. diff --git a/playbooks/debian/roles/root/tasks/main.yml b/playbooks/debian/roles/root/tasks/main.yml new file mode 100644 index 0000000..9654fa7 --- /dev/null +++ b/playbooks/debian/roles/root/tasks/main.yml @@ -0,0 +1,5 @@ +- name: root + import_tasks: root.yml + +- name: mc + import_tasks: mc.yml diff --git a/playbooks/debian/roles/root/tasks/mc.yml b/playbooks/debian/roles/root/tasks/mc.yml new file mode 100644 index 0000000..e46d622 --- /dev/null +++ b/playbooks/debian/roles/root/tasks/mc.yml @@ -0,0 +1,59 @@ +- name: "Setup root mc - check mc links" + become: true + command: test -L ~root/.cache/mc -a -L ~root/.config/mc -a -L ~root/.local/share/mc + failed_when: false + register: links_exist + +- debug: + msg: "mc links have already been created" + when: links_exist.rc == 0 + +- name: "Setup root mc - create directories for mc links" + become: true + file: + path: "~root/{{ item }}" + state: directory + mode: "0700" + loop: ['.cache', '.config', '.local/share'] + when: links_exist.rc != 0 + +- name: "Setup root mc - remove mc directories" + become: true + file: + path: "~root/{{ item }}" + state: absent + loop: ['.cache/mc', '.config/mc', '.local/share/mc'] + when: links_exist.rc != 0 + +- name: "Setup root mc - link mc directories (1)" + become: true + file: + path: "~root/{{ item }}" + state: link + src: "../.mc" + force: yes + loop: ['.cache/mc', '.config/mc'] + when: links_exist.rc != 0 + +- name: "Setup root mc - link mc directories (2)" + become: true + file: + path: "~root/{{ item }}" + state: link + src: "../../.mc" + force: yes + loop: ['.local/share/mc'] + when: links_exist.rc != 0 + +- name: "Setup root ms - overwrite files from ~phd/admin" + become: true + copy: + src: "~phd/admin/home/root/.mc/{{ item }}" + remote_src: yes + dest: ~root/.mc + owner: root + group: root + mode: "0600" + force: yes + loop: ['hotlist', 'ini', 'panels.ini'] + diff --git a/playbooks/debian/roles/root/tasks/root.yml b/playbooks/debian/roles/root/tasks/root.yml new file mode 100644 index 0000000..5824fda --- /dev/null +++ b/playbooks/debian/roles/root/tasks/root.yml @@ -0,0 +1,67 @@ +- name: "Setup ~root - overwrite files from ~phd" + become: true + copy: + src: "~phd/{{ item }}" + remote_src: yes + dest: ~root + owner: root + group: root + directory_mode: "0700" + mode: "0600" + force: yes + loop: ['.bashrc', 'admin/home/root/.profile'] + +- name: "Setup ~root - copy directories from ~phd" + become: true + copy: + src: "~phd/{{ item }}" + remote_src: yes + dest: ~root + owner: root + group: root + directory_mode: "0700" + mode: "0700" + force: no + loop: ['.mc', '.ssh', '.vim', 'bin', 'lib'] + +- name: "Setup ~root - copy files from ~phd without overwriting" + become: true + copy: + src: "~phd/{{ item }}" + remote_src: yes + dest: ~root + owner: root + group: root + directory_mode: "0700" + mode: "0600" + force: no + loop: ['.bash_logout', '.inputrc', '.less', '.lesskey', + '.screenrc', '.shellrc', '.tmux.conf', '.vimrc', + ] + +- name: "Setup ~root - create .sh_history" + become: true + file: + path: ~root/.sh_history + state: touch + owner: root + group: root + mode: "0600" + +- name: "Setup ~root - link .bash_history" + become: true + file: + path: ~root/.bash_history + src: ./.sh_history + state: link + force: yes + +- name: "Setup ~root - create tmp/" + become: true + file: + path: tmp/vim/undo + state: directory + owner: root + group: root + mode: "0700" + recurse: yes -- 2.39.5