Changeset - 18d5f555bc8b
[Not reviewed]
0 1 0
x - 21 months ago 2023-08-21 22:14:15
xbr@c3l.lu
style: initial_server, spacing in jinja2 perfected
1 file changed with 2 insertions and 2 deletions:
0 comments (0 inline, 0 general)
initial_server_setup/initial_setup.yml
Show inline comments
 
@@ -14,99 +14,99 @@
 
        upgrade: true
 
        update_cache: true
 
      tags: basic
 

	
 
    - name: Install some basic packages
 
      ansible.builtin.apt:
 
        pkg:
 
          - sudo
 
          - git
 
          - vim
 
          - python3
 
          - python3-pip
 
      tags: basic
 

	
 
    # Change Hostname
 
    - name: "Update Hostnames"
 
      ansible.builtin.hostname:
 
        name: "{{ new_hostname }}"
 
      tags: hostname
 

	
 
    # Update /etc/hosts
 
    - name: Make sure an IPV4 entry in /etc/hosts exists
 
      ansible.builtin.lineinfile:
 
        path: /etc/hosts
 
        regexp: "^{{ ansible_default_ipv4.address }}"
 
        line: "{{ ansible_default_ipv4.address }} {{ new_hostname }} {{ new_hostname }}.freifunk.lu"
 
        state: present
 
      tags: network,hostname,dns
 
    - name: Make sure an IPV6 entry in /etc/hosts exists
 
      ansible.builtin.lineinfile:
 
        path: /etc/hosts
 
        regexp: "^{{ ansible_default_ipv6.address }}"
 
        line: "{{ ansible_default_ipv6.address }} {{ new_hostname }} {{ new_hostname }}.freifunk.lu"
 
        state: present
 
      tags: network,hostname,dns
 

	
 
    # SSH security improvements (EmptyPass, PassAuth, RootLogin)
 
    - name: Disable SSH Password Auth
 
      ansible.builtin.copy:
 
        dest: /etc/ssh/sshd_config.d/disable_password_auth.conf
 
        owner: root
 
        mode: u=rw, g=r, o=r
 
        content: |
 
          '# {{ ansible_managed }}'
 
          'PasswordAuthentication no'
 
      tags: network,ssh
 
    - name: Disable SSH Empty Password
 
      ansible.builtin.copy:
 
        dest: /etc/ssh/sshd_config.d/disable_empty_password.conf
 
        owner: root
 
        mode: u=rw, g=r, o=r
 
        content: |
 
          '# {{ ansible_managed }}'
 
          'PermitEmptyPasswords no'
 
      tags: network,ssh
 
    - name: Disable SSH Root Login
 
      ansible.builtin.copy:
 
        dest: /etc/ssh/sshd_config.d/disable_root_login.conf
 
        owner: root
 
        mode: u=rw, g=r, o=r
 
        content: |
 
          '# {{ ansible_managed }}'
 
          'PermitRootLogin no'
 
      tags: network,ssh
 
    - name: Reload SSHD
 
      ansible.builtin.service:
 
        name: "sshd"
 
        state: "reloaded"
 
      tags: network,ssh
 

	
 
    # Create Freifunk Users
 
    - name: Create member users
 
      ansible.builtin.user:
 
        name: "{{ item.username }}"
 
        password: "{{ password | password_hash('sha512') }}"
 
        update_password: "on_create"
 
        groups:
 
          - sudo
 
        append: true
 
        state: present
 
      loop: "{{ users_member }}"
 
      tags: users
 
    - name: Create system users (no password)
 
      ansible.builtin.user:
 
        name: "{{ item.username }}"
 
        groups:
 
          - sudo
 
        append: true
 
        state: present
 
      loop: "{{ users_system }}"
 
      tags: users
 

	
 
    - name: Add SSH key for users from vars
 
      ansible.posix.authorized_key:
 
        user: "{{ item.username }}"
 
        state: present
 
        key: "{{ lookup('file', {{ item.key_path }} ) }}"
 
        key: "{{ lookup('file', item.key_path) }}"
 
      tags: users
 
      loop: "{{ users_member | union(users_system)}}"
 
      loop: "{{ users_member | union(users_system) }}"
0 comments (0 inline, 0 general)