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,13 +1,5 @@
|
|||||||
---
|
---
|
||||||
# tasks file for common role
|
# 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
|
- name: Create admin group
|
||||||
group: name={{ADMIN_GROUP}} state=present
|
group: name={{ADMIN_GROUP}} state=present
|
||||||
@@ -40,6 +32,8 @@
|
|||||||
dest: /etc/sudoers
|
dest: /etc/sudoers
|
||||||
regexp: "^Defaults requiretty"
|
regexp: "^Defaults requiretty"
|
||||||
line: "#Defaults requiretty"
|
line: "#Defaults requiretty"
|
||||||
|
backrefs: yes
|
||||||
|
backup: yes
|
||||||
|
|
||||||
- name: Configure NTPD
|
- name: Configure NTPD
|
||||||
template:
|
template:
|
||||||
@@ -59,22 +53,19 @@
|
|||||||
src: "{{ item.src }}"
|
src: "{{ item.src }}"
|
||||||
dest: "{{ item.dest }}"
|
dest: "{{ item.dest }}"
|
||||||
mode: "{{ item.mode }}"
|
mode: "{{ item.mode }}"
|
||||||
|
backup: yes
|
||||||
with_items:
|
with_items:
|
||||||
- { src: etc.sysconfig.network.j2,
|
- { src: etc.sysconfig.network.j2,
|
||||||
dest: /etc/sysconfig/network,
|
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,
|
- { src: etc.resolv.conf.j2,
|
||||||
dest: /etc/resolv.conf,
|
dest: /etc/resolv.conf,
|
||||||
mode: o=rw,g=r,a=r
|
mode: u+rw,a+r
|
||||||
}
|
}
|
||||||
- { src: sshd_config.j2,
|
- { src: sshd_config.j2,
|
||||||
dest: /etc/ssh/sshd_config,
|
dest: /etc/ssh/sshd_config,
|
||||||
mode: o=rw
|
mode: u+rw,a+r
|
||||||
}
|
}
|
||||||
notify:
|
notify:
|
||||||
- Restart NTPD
|
- Restart NTPD
|
||||||
@@ -90,20 +81,29 @@
|
|||||||
backup: yes
|
backup: yes
|
||||||
with_items:
|
with_items:
|
||||||
- {regexp: "^127.0.0.1.+localdomain4$",
|
- {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$",
|
- {regexp: "^::1.+localdomain6$",
|
||||||
line: "::1 localhost {{ ansible_hostname }}"
|
line: "::1 localhost {{ inventory_hostname }}"
|
||||||
}
|
}
|
||||||
- {regexp: "^{{ ansible_default_ipv4.address }}.*{{ ansible_default_ipv4.address.split('.')[-1] }}$",
|
- {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)
|
- name: Ensure correct permissions (hosts/resolv.conf)
|
||||||
file:
|
file:
|
||||||
path: "{{item}}"
|
path: "{{item}}"
|
||||||
state: touch
|
state: touch
|
||||||
mode: o+rw,g+r,a+r
|
mode: u+rw,g+r,a+r
|
||||||
with_items:
|
with_items:
|
||||||
- /etc/resolv.conf
|
- /etc/resolv.conf
|
||||||
- /etc/hosts
|
- /etc/hosts
|
||||||
@@ -157,7 +157,6 @@
|
|||||||
dest: /usr/local/bin/dynmotd
|
dest: /usr/local/bin/dynmotd
|
||||||
mode: a+x
|
mode: a+x
|
||||||
|
|
||||||
|
|
||||||
- name: Remove Dynamic MOTD in profile
|
- name: Remove Dynamic MOTD in profile
|
||||||
lineinfile:
|
lineinfile:
|
||||||
dest: /etc/profile
|
dest: /etc/profile
|
||||||
@@ -170,3 +169,13 @@
|
|||||||
regexp: "^/usr/local/bin/dynmotd"
|
regexp: "^/usr/local/bin/dynmotd"
|
||||||
line: "/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