Skip to content

Instantly share code, notes, and snippets.

@csmr
Created April 8, 2024 10:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save csmr/019d4728bde88cd48beb7a7b64888256 to your computer and use it in GitHub Desktop.
Save csmr/019d4728bde88cd48beb7a7b64888256 to your computer and use it in GitHub Desktop.
Ansible Playbook example
---
- name: Install and configure Debian desktop
hosts: all
become: yes
tasks:
- name: Install desktop environment
apt:
name: xfce4 xfce4-goodies
state: present
- name: Install common applications
apt:
name: firefox thunderbird libreoffice gimp
state: present
- name: Set timezone
copy:
dest: /etc/timezone
content: "{{ timezone }}"
- name: Configure locale
locale_gen:
name: "{{ locale }}"
state: present
- name: Create user account
user:
name: "{{ username }}"
password: "{{ user_password | password_hash('sha512') }}"
groups: sudo
append: yes
- name: Copy SSH authorized keys
authorized_key:
user: "{{ username }}"
state: present
key: "{{ item }}"
with_items: "{{ ssh_keys }}"
- name: Disable root login
lineinfile:
path: /etc/ssh/sshd_config
regexp: '^PermitRootLogin'
line: 'PermitRootLogin no'
vars:
timezone: America/Los_Angeles
locale: en_US.UTF-8
username: user
user_password: password
ssh_keys:
- "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCwINnRY0c3lq6CD1Lx75KqrJMEz8C/f9onzrqc8f8c+nWp/g+gjU4JILCkqOZblzM3h6rOJm+e8J1k8cYbf0tLTvLEaxfSnxQe9h2r9g+Y3/GPOHJhdl5NMGtW8uFA5fBqihR7qJdyEmTvphzDq0YVgBbyU9k+we6oKFQDY6rbDfrX73Tp1LlYROyKC4UD6h+L+WpCp+s9cFJE6EnD1wK2Mqj+DxXzBKkE3Y5e7QN0QAzWKg93bKNA1ujK5yHE3VaUwEgw2oKfTQXVZRrF6l1g6iIy3RODgzyPPbJ3/WLX/D3l8S4iUu0cAwEAAQ== user@laptop"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment