You've already forked ansible-role-common
Changed to lineinfile with regexp to stop breaking dGit custom host confiurations
This commit is contained in:
@@ -1,14 +1,6 @@
|
||||
---
|
||||
# tasks file for common role
|
||||
- name: Set Hostname
|
||||
hostname: name="{{ inventory_hostname }}"
|
||||
|
||||
- name: Change root password
|
||||
user:
|
||||
name: root
|
||||
password: "{{ root_pwd }}"
|
||||
changed_when: false
|
||||
|
||||
|
||||
- name: Create admin group
|
||||
group: name={{ADMIN_GROUP}} state=present
|
||||
|
||||
@@ -40,6 +32,8 @@
|
||||
dest: /etc/sudoers
|
||||
regexp: "^Defaults requiretty"
|
||||
line: "#Defaults requiretty"
|
||||
backrefs: yes
|
||||
backup: yes
|
||||
|
||||
- name: Configure NTPD
|
||||
template:
|
||||
@@ -59,28 +53,25 @@
|
||||
src: "{{ item.src }}"
|
||||
dest: "{{ item.dest }}"
|
||||
mode: "{{ item.mode }}"
|
||||
backup: yes
|
||||
with_items:
|
||||
- { src: etc.sysconfig.network.j2,
|
||||
dest: /etc/sysconfig/network,
|
||||
mode: o+rw
|
||||
mode: u+rw,a+r
|
||||
}
|
||||
#- { src: etc.hosts.j2,
|
||||
# dest: /etc/hosts,
|
||||
# mode: o=rw,g=r,a=r
|
||||
# }
|
||||
- { src: etc.resolv.conf.j2,
|
||||
dest: /etc/resolv.conf,
|
||||
mode: o=rw,g=r,a=r
|
||||
mode: u+rw,a+r
|
||||
}
|
||||
- { src: sshd_config.j2,
|
||||
dest: /etc/ssh/sshd_config,
|
||||
mode: o=rw
|
||||
mode: u+rw,a+r
|
||||
}
|
||||
notify:
|
||||
- Restart NTPD
|
||||
- Restart SSH
|
||||
tags: dns
|
||||
|
||||
|
||||
- name: Ensure hosts file correct
|
||||
lineinfile:
|
||||
dest: /etc/hosts
|
||||
@@ -90,20 +81,29 @@
|
||||
backup: yes
|
||||
with_items:
|
||||
- {regexp: "^127.0.0.1.+localdomain4$",
|
||||
line: "127.0.0.1 localhost {{ ansible_hostname }}"
|
||||
line: "127.0.0.1 localhost {{ inventory_hostname }}"
|
||||
}
|
||||
- {regexp: "^::1.+localdomain6$",
|
||||
line: "::1 localhost {{ ansible_hostname }}"
|
||||
line: "::1 localhost {{ inventory_hostname }}"
|
||||
}
|
||||
- {regexp: "^{{ ansible_default_ipv4.address }}.*{{ ansible_default_ipv4.address.split('.')[-1] }}$",
|
||||
line: "{{ ansible_default_ipv4.address }} {{ ansible_hostname }}.{{ domain }} {{ ansible_hostname }}"
|
||||
}
|
||||
line: "{{ ansible_default_ipv4.address }} {{ inventory_hostname }}.{{ domain }} {{ inventory_hostname }}"
|
||||
}
|
||||
- {regexp: "^127.0.0.1.+{{ ansible_nodename.split('.')[0] }}$",
|
||||
line: "127.0.0.1 localhost {{ inventory_hostname }}"
|
||||
}
|
||||
- {regexp: "^::1.+{{ ansible_nodename.split('.')[0] }}$",
|
||||
line: "::1 localhost {{ inventory_hostname }}"
|
||||
}
|
||||
- {regexp: "^{{ ansible_default_ipv4.address }}.*{{ ansible_nodename.split('.')[0] }}$",
|
||||
line: "{{ ansible_default_ipv4.address }} {{ inventory_hostname }}.{{ domain }} {{ inventory_hostname }}"
|
||||
}
|
||||
|
||||
- name: Ensure correct permissions (hosts/resolv.conf)
|
||||
file:
|
||||
path: "{{item}}"
|
||||
state: touch
|
||||
mode: o+rw,g+r,a+r
|
||||
mode: u+rw,g+r,a+r
|
||||
with_items:
|
||||
- /etc/resolv.conf
|
||||
- /etc/hosts
|
||||
@@ -157,7 +157,6 @@
|
||||
dest: /usr/local/bin/dynmotd
|
||||
mode: a+x
|
||||
|
||||
|
||||
- name: Remove Dynamic MOTD in profile
|
||||
lineinfile:
|
||||
dest: /etc/profile
|
||||
@@ -169,4 +168,14 @@
|
||||
dest: /etc/profile.d/motd.sh
|
||||
regexp: "^/usr/local/bin/dynmotd"
|
||||
line: "/usr/local/bin/dynmotd"
|
||||
create: yes
|
||||
create: yes
|
||||
|
||||
- name: Ensure Hostname is set
|
||||
hostname:
|
||||
name: "{{ inventory_hostname }}.{{ domain }}"
|
||||
|
||||
- name: Change root password
|
||||
user:
|
||||
name: root
|
||||
password: "{{ root_pwd }}"
|
||||
changed_when: false
|
||||
Reference in New Issue
Block a user