2019-09-14 11:49:23 -05:00
|
|
|
#!/usr/bin/ansible-playbook
|
|
|
|
# vim:ft=ansible:
|
|
|
|
---
|
2020-06-01 04:55:40 -05:00
|
|
|
- name: Assure user
|
2019-09-14 11:49:23 -05:00
|
|
|
user:
|
2020-06-01 04:54:38 -05:00
|
|
|
name: "{{ user_username }}"
|
|
|
|
shell: "{{ user_shell }}"
|
|
|
|
password: "{{ user_password }}"
|
2019-09-14 11:49:23 -05:00
|
|
|
become: yes
|
2020-09-02 22:21:07 -05:00
|
|
|
- name: Add user to sudo
|
|
|
|
user:
|
|
|
|
name: "{{ user_username }}"
|
|
|
|
groups: sudo
|
2020-09-02 22:49:46 -05:00
|
|
|
append: yes
|
2020-09-02 22:21:07 -05:00
|
|
|
become: yes
|
2020-09-04 07:05:54 -05:00
|
|
|
when: ansible_os_family == "Debian"
|
2020-09-02 22:21:07 -05:00
|
|
|
- name: Add user to wheel
|
|
|
|
user:
|
|
|
|
name: "{{ user_username }}"
|
|
|
|
groups: wheel
|
2020-09-02 22:49:46 -05:00
|
|
|
append: yes
|
2020-09-02 22:21:07 -05:00
|
|
|
become: yes
|
2020-09-04 06:16:30 -05:00
|
|
|
when: ansible_os_family != "Debian"
|
2020-02-05 20:23:20 -06:00
|
|
|
- name: Bootstrap user
|
|
|
|
block:
|
2020-07-05 08:46:47 -05:00
|
|
|
- name: Assure .ssh directory
|
|
|
|
file:
|
|
|
|
path: $HOME/.ssh
|
|
|
|
state: directory
|
|
|
|
mode: "0700"
|
2020-06-28 08:27:46 -05:00
|
|
|
- name: Generate keypair
|
|
|
|
openssh_keypair:
|
2020-07-28 06:44:33 -05:00
|
|
|
comment: "{{ user_username }}@{{ inventory_hostname_short }}"
|
2020-06-28 08:36:57 -05:00
|
|
|
path: $HOME/.ssh/id_ed25519
|
2020-06-28 08:27:46 -05:00
|
|
|
mode: "0600"
|
|
|
|
register: keypair
|
|
|
|
- name: Register keypair with Gitea
|
|
|
|
uri:
|
|
|
|
url: "https://git.9iron.club/api/v1/user/keys"
|
|
|
|
method: POST
|
|
|
|
headers:
|
|
|
|
accept: "application/json"
|
|
|
|
Authorization: "token {{ gitea_api_token }}"
|
|
|
|
body_format: json
|
|
|
|
body:
|
|
|
|
key: "{{ keypair.public_key }}"
|
|
|
|
read_only: yes
|
2020-07-28 07:42:27 -05:00
|
|
|
title: "{{ inventory_hostname }}-ed25519"
|
2020-06-28 08:27:46 -05:00
|
|
|
status_code: 201
|
|
|
|
when: keypair is changed
|
|
|
|
- name: Configure authorized hosts
|
2020-02-05 20:23:20 -06:00
|
|
|
authorized_key:
|
2020-06-01 04:54:38 -05:00
|
|
|
user: "{{ user_username }}"
|
2020-02-05 20:23:20 -06:00
|
|
|
manage_dir: yes
|
2020-06-01 04:54:38 -05:00
|
|
|
key: "{{ item.key }}"
|
|
|
|
state: "{{ item.state }}"
|
|
|
|
loop:
|
|
|
|
- { key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDc03Q21k7rDuIbZ91dIMOSAM7EpT75YFzOoYL6CfHLZbRDsYTVgUSHYL9lfgGiW9CYL9Gp8QT9eLzIdfgn4e8OMMuoW1jayM9nj6iY3tmWlinuzs535j04Us/aY1Gka+f0qf/vJfRAwO0VN92xmLxW4pQMD/r5DKQ3yppvohnAAPeOhoFeLbEPiBgb1ktNxtQF9GdIOdDIEE+dV0UA07dJskTdJGG9Zbff7VEcQXknhaLdclye+BHlNkRv+MvFu4jPnBNttPiM4TSBgOD88U68M6MsYBJ+2e+7cTiO2DWy9bTtAnhWHD468fdS3S9h62l2lsrGBa5dRpc8RCpPXFo/ salt@dsk-cstm-0", state: present }
|
|
|
|
- { key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDyOzdOFNONNhr++/2L3iSN04JsLwYHkapslDMEImI0x4chvdfdA9OkEOZHP5EoMUG6uWL3xZZdQ9Egp931oHDc4W5ylPQ1VtqQ2vcyffCfBTOEaUeEgw2tHBDngMqBgTajMSFvTbaC7JNSIdcGP1KTCCYZ3f8DPjVmG8FAKq1kDnCyI4sXHQswi/AbIBrOsWSW+qjrQdD/jU7T2LPQbU9FB+afinDizhGXUzkmbRkOD5z/YsyrWDfaKhGS4EwJpZbEwT7ocnCaQSa74xYLwUlBONhg3u2wq00mrh7vc2WbeGB7VoCsojPIj5r6KoCKzRBVog2HLQ4W7QqfSW/nXR21 salt@lap-th-e560-0", state: present }
|
2020-08-07 13:26:50 -05:00
|
|
|
- { key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCsZVQJr3d5G9nhlAilU8SKK7AInw8bgUTbIof7LEPD16Fg21KKAIcpYqWgw53EwuwFN8KJjDHKQasfnGZ++vIdpaNKB5HAAHapHxMREpwKzDf9Z+phfi2S5rdIodeCz62DVo0DSd4NZGF1q2FGgVTIsnOVLRBiu5xBIP6BElMmAn+afsBHiuN68YVUxqTnwX+brQXcxhG/D0UuNHUgf2VZ95vNktgad03/1g9FbKI4CIVoUazHeavTFzOYewfSzOGo9T6VOxe0Tm/GYjokO+XGtn5LtITFAEjAMEyhUb3JCtmPuof153BaP11ELqURUp1Os5Spxq2nsxGpdSebzty157uf9wFPGnbsSk5ehEE9pQodzCZlrHu85oKFGtwtdYmAvQd8LvrIb+tRFV2LX3AL/H0KdAGOCBvQG0bIAWmosZSzTT0zC1ESA97ncpzP8VYJJtwvhxyJOpsA3udHScQAZllrTjh6S18RJts1GtLv2d7ogFBzRAGn+/dsekX5ghU= salt@lap-s76-lemp9-0", state: present }
|
2020-09-02 17:11:30 -05:00
|
|
|
- { key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDgLG6Y+R58AaS8hxrAVtpYRon1JiXG65KoHLR1hr8GtQXAaJuTIzzvD3LJbZ3OxSctZCzfu85SZ+7ex6yHAD0RfPASAGZarHOWSFuTULtIYaz0lGopfmHrVT9yV2df0zhqz3E2FEJaMe1CXkDufJrD3IkPZSTd24NY83hJGWxSM9SbiCqAf+c3DSWWhCC75WXdIfPs6d5CF/pYY6T1kD9AJC4K6JhP3LtieFBGZfpd6EamZ/Y1wvlFbkjV+rLDvYE4BF4WNYcJP1CTEgtOTAbACMqSdQ6544JUVvKNE7J9haOzTK0gYcp05zvgHvgju9TuPizlYEjPgypxNZBPXQisat3KXLenGS4+4gLloFrkZ4f2IfJidLrBd99GAina2OMHsCfQrazhuzvIoXI/5ww+k28GgF264HA8ZNkhPgZf3tbDmSHIZPvshRRvYOfURwiwl9T9xwdoJet5qdPrXk6EmX6f5TUIUdB8eeXcLecQDfvwgbDePdxz02sEw4LymK0= salt@ph-pine-0", state: present }
|
2020-02-05 20:23:20 -06:00
|
|
|
- name: Check for dotfile initialization
|
|
|
|
stat: path=$HOME/.dotfiles
|
|
|
|
register: p
|
2020-02-06 00:35:06 -06:00
|
|
|
- name: Initialize dotfiles
|
|
|
|
block:
|
|
|
|
- name: Clone bootstrap script
|
|
|
|
git:
|
|
|
|
accept_hostkey: yes
|
2020-04-30 13:26:16 -05:00
|
|
|
repo: git@git.9iron.club:salt/bootstrap
|
2020-02-06 00:35:06 -06:00
|
|
|
dest: $HOME/bootstrap
|
|
|
|
depth: 1
|
|
|
|
force: yes
|
|
|
|
- name: Execute bootstrap script
|
2020-08-10 23:38:08 -05:00
|
|
|
shell: "cd && ~/bootstrap/bootstrap.sh > bootstrap.log 2>&1"
|
2020-02-06 00:35:06 -06:00
|
|
|
- name: Disable untracked files on dotfiles
|
|
|
|
git_config:
|
|
|
|
name: status.showUntrackedFiles
|
|
|
|
value: "no"
|
|
|
|
scope: local
|
|
|
|
repo: ~/.dotfiles
|
|
|
|
- name: Remove bootstrap script directory
|
|
|
|
file:
|
|
|
|
path: ~/bootstrap
|
|
|
|
state: absent
|
2020-02-05 20:23:20 -06:00
|
|
|
when: not p.stat.exists
|
2019-09-15 02:30:46 -05:00
|
|
|
become: yes
|
2020-06-01 04:54:38 -05:00
|
|
|
become_user: "{{ user_username }}"
|