Last active
August 21, 2020 15:33
-
-
Save jnovack/bd7b4f052e3a74f18b47c293f0b9a252 to your computer and use it in GitHub Desktop.
ansible bootstrap a clean installation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- name: Bootstrap Alpine | |
hosts: all | |
gather_facts: false | |
become: no | |
vars: | |
ansible_python_interpreter: auto_silent | |
tasks: | |
## Alpine does not have python3 installed, must install raw. | |
- name: Install pre-requisities | |
raw: apk update && apk add --no-cache python3 | |
## Once python3 is installed, we can continue with the rest of the boostrapping. | |
- name: Import bootstrap.yml | |
import_playbook: bootstrap.yml |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- name: Bootstrap | |
hosts: all | |
gather_facts: false | |
become: no | |
vars: | |
ansible_python_interpreter: auto_silent | |
tasks: | |
- name: Install base packages | |
package: name={{ item }} state=present | |
loop: [ 'sudo' ] | |
- name: set sshd service to start on boot | |
service: | |
name: sshd | |
state: started | |
enabled: yes | |
runlevel: default | |
- name: create ansible user | |
user: | |
name: ansible | |
comment: ansible | |
password: '' | |
- name: Add ssh-key as authorized_key for ansible | |
authorized_key: | |
user: ansible | |
state: present | |
key: "{{ lookup('file', lookup('env','HOME') + '/.ssh/id_rsa.pub') }}" | |
- name: Permit ansible to sudo | |
lineinfile: | |
path: /etc/sudoers.d/ansible | |
state: present | |
create: yes | |
regexp: '^ansible.*' | |
line: 'ansible ALL=(ALL) NOPASSWD: ALL' | |
validate: '/usr/sbin/visudo -cf %s' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment