Changeset - 31778396563a
[Not reviewed]
0 0 1
Max Wahl (Fantawams) - 3 years ago 2021-12-20 20:03:32
fantawams@c3l.lu
Ansible Playbook for initial setup. Hostname part does not work.
1 file changed with 112 insertions and 0 deletions:
0 comments (0 inline, 0 general)
initial_setup.yml
Show inline comments
 
new file 100644
 
---
 
# Defining the remote server where the package will be deployed
 
- hosts: initial
 
  remote_user: root
 
  become: yes
 
  become_method: sudo
 
  vars:
 
    password: Welcome1234
 
  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 }}"
 
    - name: 'Add hostname to /etc/hosts'
 
      lineinfile:
 
        path: /etc/hosts
 
        regexp: '^127\.0\.0\.1[ \t]+localhost'
 
        line: '127.0.0.1 localhost {{ new_hostname }}'
 
        state: present
 

	
 
# 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)