Changeset - 1fa2261908ab
[Not reviewed]
0 0 2
Max Wahl (Fantawams) - 3 years ago 2022-02-18 07:37:27
fantawams@c3l.lu
Added ReadMe file for initial server setup.
2 files changed with 144 insertions and 0 deletions:
0 comments (0 inline, 0 general)
initial_server_setup/ReadMe.md
Show inline comments
 
new file 100644
 
This will Ansibel playbook will do the very basic server setup. 
 

	
 
It will install the following packadges:
 
	- sudo
 
        - git
 
        - vim
 
        - python3
 
        - python3-pip
 
        
 
It will update the hostname.
 
It will update the IPV4 and IPV6 address withn the new hostname.
 

	
 
It will create the following users:
 
	- fantawams
 
	- orimpe
 
	- metalgamer
 
	- xbr
 
	- fflux
 
It will update all packadges to its lates version.
initial_server_setup/initial_setup.yml
Show inline comments
 
new file 100644
 
---
 
# Defining the remote server where the package will be deployed
 
- hosts: test
 
  remote_user: root
 
  become: yes
 
  become_method: sudo
 
  vars:
 
    password: Welcome1234
 
    ipv4: var=hostvars[initial]['ansible_default_ipv4']['address']
 
    old_hostname: filter=ansible_hostname
 
  tasks:
 

	
 
# Update and install aptitude packadge
 
    - name: "APT: Install aptitude package"
 
      apt:
 
        name: aptitude
 
        force_apt_get: yes
 

	
 
    - name: "Update packages"
 
      apt:
 
        update_cache: yes # apt-get update
 
        upgrade: full
 

	
 
    - name: UpdateRaw
 
      shell: apt-get update -y
 
    - name: UpgradeRaw
 
      shell: apt-get upgrade -y
 

	
 
# Installing the sudo, git, vim and python3 packadges on ther servers 
 
    - name: Install a list of packages
 
      apt:
 
        pkg:
 
        - sudo
 
        - git
 
        - vim
 
        - python3
 
        - python3-pip
 
        
 
# Updating all packages to their latest version
 
    - name: Update all packages to their latest version
 
      apt:
 
        name: "*"
 
        state: latest
 

	
 
# Change Hostname
 
    - name: "Update Hostnames"
 
      hostname:
 
        name: "{{ new_hostname }}"
 

	
 
# Updaet /etc/hosts
 
    - name: Make sure an IPV4 entry in /etc/hosts exists
 
      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
 
      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
 

	
 
# Create Freifunk Users
 
    - name: Create a login user fantawams
 
      user:
 
        name: fantawams
 
        password: "{{ password | password_hash('sha512') }}"
 
        groups: # Empty by default, here we give it some groups
 
         - sudo
 
        state: present
 
        shell: /bin/bash       # Defaults to /bin/bash
 
        system: no             # Defaults to no
 
        createhome: yes        # Defaults to yes
 
        home: /home/fantawams  # Defaults to /home/<username>
 

	
 
    - name: Create a login user orimpe
 
      user:
 
        name: orimpe
 
        password: "{{ password | password_hash('sha512') }}"
 
        groups: # Empty by default, here we give it some groups
 
         - sudo
 
        state: present
 
        shell: /bin/bash       # Defaults to /bin/bash
 
        system: no             # Defaults to no
 
        createhome: yes        # Defaults to yes
 
        home: /home/orimpe     # Defaults to /home/<username>
 

	
 
    - name: Create a login user metalgamer
 
      user:
 
        name: metalgamer
 
        password: "{{ password | password_hash('sha512') }}"
 
        groups: # Empty by default, here we give it some groups
 
         - sudo
 
        state: present
 
        shell: /bin/bash       # Defaults to /bin/bash
 
        system: no             # Defaults to no
 
        createhome: yes        # Defaults to yes
 
        home: /home/metalgamer  # Defaults to /home/<username>
 

	
 
    - name: Create a login user xbr   
 
      user:
 
        name: xbr   
 
        password: "{{ password | password_hash('sha512') }}"
 
        groups: # Empty by default, here we give it some groups
 
         - sudo
 
        state: present
 
        shell: /bin/bash       # Defaults to /bin/bash
 
        system: no             # Defaults to no
 
        createhome: yes        # Defaults to yes
 
        home: /home/xbr     # Defaults to /home/<username>
 

	
 
    - name: Create a login user fflux
 
      user:
 
        name: fflux
 
        password: "{{ password | password_hash('sha512') }}"
 
#        groups: # Empty by default, here we give it some groups
 
        state: present
 
        shell: /bin/bash       # Defaults to /bin/bash
 
        system: no             # Defaults to no
 
        createhome: yes        # Defaults to yes
 
        home: /home/fflux     # Defaults to /home/<username>
0 comments (0 inline, 0 general)