]> git.phdru.name Git - ansible.git/commitdiff
Feat(init-system2): Setup ~root by copying files from ~phd
authorOleg Broytman <phd@phdru.name>
Tue, 23 Jul 2019 22:12:57 +0000 (01:12 +0300)
committerOleg Broytman <phd@phdru.name>
Tue, 23 Jul 2019 23:55:47 +0000 (02:55 +0300)
playbooks/debian/init-system2.yml
playbooks/debian/roles/root/README.txt [new file with mode: 0644]
playbooks/debian/roles/root/tasks/main.yml [new file with mode: 0644]
playbooks/debian/roles/root/tasks/mc.yml [new file with mode: 0644]
playbooks/debian/roles/root/tasks/root.yml [new file with mode: 0644]

index 0efdf4aabc4be770da83b13dfb8e5362bdce4a33..335299e41bb357469427c732f5b18edbfe38325b 100644 (file)
@@ -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 (file)
index 0000000..e970e2a
--- /dev/null
@@ -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 (file)
index 0000000..9654fa7
--- /dev/null
@@ -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 (file)
index 0000000..e46d622
--- /dev/null
@@ -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 (file)
index 0000000..5824fda
--- /dev/null
@@ -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