Changeset - c55538539a4e
[Not reviewed]
0 1 0
Max Wahl (Fantawams) - 3 years ago 2021-12-25 22:03:18
fantawams@c3l.lu
Update for initial setup playbook. etc/hosts part works now.
1 file changed with 17 insertions and 4 deletions:
0 comments (0 inline, 0 general)
initial_setup.yml
Show inline comments
 
---
 
# Defining the remote server where the package will be deployed
 
- hosts: initial
 
- 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
 
@@ -44,12 +46,23 @@
 
    - name: "Update Hostnames"
 
      hostname:
 
        name: "{{ new_hostname }}"
 
    - name: 'Add hostname to /etc/hosts'
 

	
 
# 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: '^127\.0\.0\.1[ \t]+localhost'
 
        line: '127.0.0.1 localhost {{ new_hostname }}'
 
        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
0 comments (0 inline, 0 general)