about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--base_apps.yml33
-rw-r--r--bootstrap.yml33
-rw-r--r--roles/base_users/tasks/main.yml20
3 files changed, 86 insertions, 0 deletions
diff --git a/base_apps.yml b/base_apps.yml
new file mode 100644
index 0000000..b07f991
--- /dev/null
+++ b/base_apps.yml
@@ -0,0 +1,33 @@
+---
+  - name: Base
+    hosts: tamriel
+    remote_user: ansible_worker
+    become: yes
+    tasks:
+    - apt_key:
+        url: https://download.docker.com/linux/debian/gpg
+    - apt: name=apt-transport-https
+    - apt_repository:
+        repo: deb [arch=amd64] https://download.docker.com/linux/debian stretch stable 
+        update_cache: true
+    - name: Base packages
+      apt:
+        name: "{{ item }}"
+      with_items:
+      - tmux
+      - htop
+      - nginx
+      - syncthing
+      - docker-ce
+      #- wireguard
+      - hugo
+      - rsync
+      - python-pip
+    - apt:
+        upgrade: full
+    - pip:
+        name: "{{ item }}"
+      with_items:
+      - docker
+      - docker-compose
+
diff --git a/bootstrap.yml b/bootstrap.yml
new file mode 100644
index 0000000..012ce90
--- /dev/null
+++ b/bootstrap.yml
@@ -0,0 +1,33 @@
+---
+  - name: Bootstrap base systems
+    hosts: tamriel
+    remote_user: root
+    vars:
+      users:
+      - login: pawel
+        groups: ['sudo', 'remote_access', 'docker']
+        pubkey: "{{ lookup('file', '/home/pawel/.ssh/id_rsa.pub') }}"
+        shell: /bin/zsh
+      - login: ansible_worker
+        groups: ['sudo', 'remote_access', 'docker']
+        pubkey: "{{ lookup('file', '/home/pawel/.ssh/id_rsa.pub') }}"
+        shell: /bin/bash
+    roles:
+    - base_users
+    tasks:
+    - name: zsh
+      apt: name=zsh
+    #- name: Allow paswordless sudo
+    #  lineinfile:
+    #    dest: /etc/sudoers
+    #    state: present
+    #    regexp: "^%sudo"
+    #    line: "%sudo ALL=(ALL) NOPASSWD: ALL"
+    #    validate: '/usr/sbin/visudo -cf %s'
+    - file:
+        path: /home/pawel/.zshrc
+        owner: pawel
+        group: pawel
+        state: touch
+        mode: 0660
+
diff --git a/roles/base_users/tasks/main.yml b/roles/base_users/tasks/main.yml
new file mode 100644
index 0000000..bf9f6f8
--- /dev/null
+++ b/roles/base_users/tasks/main.yml
@@ -0,0 +1,20 @@
+---
+- name: Create docker group
+  group: name=docker state=present
+
+- name: Create remote_access group
+  group: name=remote_access state=present
+
+- name: Add users
+  user: 
+    name: "{{ item.login }}"
+    groups: "users{% if 'groups' in item %},{{ item.groups|join(',') }}{% endif %}"
+    shell: "{{ item.shell }}"
+  with_items: "{{ users }}"
+
+- name: Setup authorized keys for users
+  authorized_key:
+    user: "{{ item.login }}"
+    key: "{{ item.pubkey }}"
+  with_items: "{{ users }}"
+