Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ansible/**/*.yml: Add marker to blockinfile and fix regexes #52

Merged
merged 3 commits into from
Jun 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ansible/tasks/dns/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@
- name: Use DNS root hints from the dns-root-data Debian package
blockinfile:
path: /etc/unbound/unbound.conf.d/debian.conf
marker: "# {mark} ANSIBLE - DNS Root Hints"
create: true
block: |
server:
root-hints: "/usr/share/dns/root.hints"
- name: Prefetch popular domains before the cache expires
blockinfile:
path: /etc/unbound/unbound.conf.d/prefetch.conf
marker: "# {mark} ANSIBLE - Prefetch popular domains"
create: true
block: |
server:
Expand All @@ -42,6 +44,7 @@
- name: Enable RFC 7816 "DNS Query Name Minimisation to Improve Privacy"
blockinfile:
path: /etc/unbound/unbound.conf.d/qname-minimisation.conf
marker: "# {mark} ANSIBLE - Enable RFC 7816"
create: true
block: |
server:
Expand Down
2 changes: 1 addition & 1 deletion ansible/tasks/hashbang/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
- template:
src: "{{ item.src }}"
dest: "/{{ item.path | regex_replace('.j2','') }}"
mode: "{{ item.mode }}"
mode: "{{ item.mode[1] == '7' and '0755' or '0644' }}"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unfortunately necessary because i think ansible-pull strips group and all permissions leading to bad permission issues

with_filetree: "tasks/hashbang/templates"
when: item.state == 'file'

Expand Down
3 changes: 2 additions & 1 deletion ansible/tasks/ldap-nss/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
- name: Configure ssh to use sss for authorized-keys
blockinfile:
path: /etc/ssh/sshd_config
marker: ""
marker: "# {mark} ANSIBLE - sss config for ssh"
block: |
AuthorizedKeysFile none
AuthorizedKeysCommand /usr/bin/sss_ssh_authorizedkeys
Expand All @@ -11,6 +11,7 @@
- name: Configure sssd to use custom ldap server
blockinfile:
path: /etc/sssd/sssd.conf
marker: "# {mark} ANSIBLE - LDAP configuration for sss"
mode: 0600
create: true
block: |
Expand Down
8 changes: 4 additions & 4 deletions ansible/tasks/mail/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@
- name: Update maildir for console login
lineinfile:
path: /etc/pam.d/login
regexp: "^session optional pam_mail.so standard"
line: "session optional pam_mail.so dir=~/Mail standard"
regexp: "^session +optional +pam_mail.so"
line: "session optional pam_mail.so dir=~/Mail standard"
- name: Update maildir for sshd login
lineinfile:
path: /etc/pam.d/sshd
regexp: "^session optional pam_mail.so standard noenv"
line: "session optional pam_mail.so dir=~/Mail standard noenv"
regexp: "^session +optional +pam_mail.so"
line: "session optional pam_mail.so dir=~/Mail standard noenv"

- name: Setup msmtprc for hashbang smtp
copy:
Expand Down
1 change: 1 addition & 0 deletions ansible/tasks/misc/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
- name: Configure systemd for increased resource accounting
blockinfile:
path: /etc/systemd/system.conf
marker: "# {mark} ANSIBLE - Config for better resource accounting"
block: |
DefaultCPUAccounting=yes
DefaultBlockIOAccounting=yes
Expand Down
4 changes: 4 additions & 0 deletions ansible/tasks/security/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@
- name: Filesystem security settings
blockinfile:
path: /etc/fstab
marker: "# {mark} ANSIBLE - Filesystem Security Settings"
block: |
proc /proc proc defaults,hidepid=2 0 0
udev /dev devtmpfs defaults,nosuid,noatime 0 0
Expand All @@ -135,6 +136,7 @@
- name: Use pty instead of tty for sudoers
blockinfile:
path: /etc/sudoers
marker: "# {mark} ANSIBLE - PTY configuration for users"
block: |
Defaults !requiretty, !tty_tickets
Defaults use_pty
Expand Down Expand Up @@ -179,6 +181,7 @@
- name: enable spoof protection via reverse-path filter
blockinfile:
path: /etc/sysctl.conf
marker: "# {mark} ANSIBLE - Spoof Protection via Reverse-Path Filter"
block: |
net.ipv4.conf.default.rp_filter=1
net.ipv4.conf.all.rp_filter=1
Expand Down Expand Up @@ -227,6 +230,7 @@
- name: Allow root ssh via hardcoded keys as failsafe
blockinfile:
path: /etc/ssh/sshd_config
marker: "# {mark} ANSIBLE - Root SSH via hardcoded keys"
block: |
Match User root
AuthorizedKeysFile .ssh/authorized_keys
Expand Down