This commit is contained in:
aynic.os
2021-07-14 20:38:30 +01:00
parent e1f9ef7de9
commit 3ffea66ba8
101 changed files with 3601 additions and 939 deletions
+10 -9
View File
@@ -10,23 +10,24 @@
regex: '^default_kernel_opts="((?!.*clocksource=tsc tsc=reliable).*)"$'
- name: boot - stat config file
changed_when: false
register: boot_config_stat
with_items: '{{boot_config|default([])}}'
stat:
path: '{{item.dest}}'
with_items: '{{boot_config|default([])}}'
changed_when: false
register: boot_config_stat
- name: boot - update config
become: yes
when: item.1.stat.exists
with_together:
- '{{boot_config|default([])}}'
- '{{boot_config_stat.results}}'
lineinfile:
backrefs: true
dest: '{{item.0.dest}}'
line: '{{item.0.line}}'
regex: '{{item.0.regex}}'
with_together:
- '{{boot_config|default([])}}'
- '{{boot_config_stat.results}}'
when: item.1.stat.exists
register: boot_config_handler_notify
become: yes
notify:
- update boot config
register: boot_config_handler_notify
+10 -9
View File
@@ -2,11 +2,15 @@
# file: tasks/cloudinit.yml
- name: cloudinit - install cloud-init packages
when: hosts_cloudinit_enable|default(false) and ansible_os_family|lower != "alpine"
package: name="cloud-init" state="present"
become: yes
when: hosts_enable_cloudinit|default(false) and ansible_os_family|lower != "alpine"
- name: cloudinit - install cloud-init packages
- name: cloudinit - alpine - install cloud-init packages
when: hosts_cloudinit_enable|default(false) and ansible_os_family|lower == "alpine"
with_items:
- { "name": "cloud-init", "state": "present" }
- { "name": "cloud-init-openrc", "state": "present" }
apk:
name: "{{ item.name}}"
state: "{{ item.state }}"
@@ -16,32 +20,29 @@
- http://dl-cdn.alpinelinux.org/alpine/edge/community
- http://dl-cdn.alpinelinux.org/alpine/latest-stable/main
- http://dl-cdn.alpinelinux.org/alpine/latest-stable/community
with_items:
- { "name": "cloud-init", "state": "present" }
- { "name": "cloud-init-openrc", "state": "present" }
become: yes
when: hosts_enable_cloudinit|default(false) and ansible_os_family|lower == "alpine"
- name: cloudinit - update /etc/cloud/cloud.cfg
when: hosts_cloudinit_enable|default(false)
template:
src: cloud.cfg.j2
dest: /etc/cloud/cloud.cfg
force: yes
when: hosts_enable_cloudinit|default(false)
- name: cloudinit - activate service
when: hosts_cloudinit_enable|default(false) and ansible_service_mgr|lower != "openrc"
service:
name: cloud-init
state: started
enabled: yes
when: hosts_enable_cloudinit|default(false) and ansible_service_mgr|lower != "openrc"
become: yes
- name: cloudinit - activate service (openrc)
when: hosts_cloudinit_enable|default(false) and ansible_service_mgr|lower == "openrc"
service:
name: cloud-init
state: started
enabled: yes
runlevel: boot
when: hosts_enable_cloudinit|default(false) and ansible_service_mgr|lower == "openrc"
become: yes
+6 -5
View File
@@ -15,24 +15,25 @@
copy: src=../files/{{item}} dest={{item}} owner=root group=root mode=0755
become: yes
- name: files - copy systemd files
- name: files - systemd - copy files
when: ansible_service_mgr|lower == "systemd"
with_items:
- /etc/systemd/system/zram.service
copy: src=../files/{{item}} dest={{item}} owner=root group=root mode=0644
when: ansible_service_mgr|lower == "systemd"
become: yes
- name: files - copy openrc files
- name: files - openrc - copy files
when: ansible_service_mgr|lower == "openrc"
with_items:
- /etc/init.d/zram-openrc
- /etc/local.d/ansible.start
copy: src=../files/{{item}} dest={{item}} owner=root group=root mode=0755
when: ansible_service_mgr|lower == "openrc"
become: yes
- name: files - get remote binary files
with_items:
- https://raw.githubusercontent.com/dylanaraps/pfetch/master/pfetch
get_url: url={{item}} dest=/usr/local/bin owner=root group=root mode=0755
become: yes
ignore_errors: true
become: yes
+1
View File
@@ -10,3 +10,4 @@
version: "{{ item.version|default('HEAD') }}"
ignore_errors: true
become: yes
@@ -1,12 +1,13 @@
---
# file: tasks/group.yml
# file: tasks/groups.yml
- name: group - create dns group
- name: groups - create dns group
when: ansible_os_family|lower != "alpine"
group: gid="11" name="dns" state="present" system="yes"
become: yes
when: ansible_os_family|lower != "alpine"
- name: group - add me to the dns group
- name: groups - add me to the dns group
when: ansible_os_family|lower != "alpine" and ansible_user_uid != "0"
user: name="{{ansible_user_id}}" groups=dns append=yes
become: yes
when: ansible_os_family|lower != "alpine" and ansible_user_uid != "0"
+6 -2
View File
@@ -19,15 +19,19 @@
- import_tasks: git.yml
tags:
- git
- import_tasks: groups.yml
tags:
- groups
- import_tasks: packages.yml
tags:
- packages
- import_tasks: service.yml
- import_tasks: services.yml
tags:
- service
- services
- import_tasks: ssh.yml
tags:
- ssh
- import_tasks: user.yml
tags:
- user
+2 -1
View File
@@ -2,6 +2,7 @@
# file: tasks/packages.yml
- name: packages - install/remove packages
with_items: "{{ hosts_packages_common|default([]) + hosts_packages_distro|default([]) + hosts_packages|default([]) }}"
package: name="{{item.name}}" state="{{item.state}}"
with_items: "{{hosts_packages_common|default([]) + hosts_packages_distro|default([]) + hosts_packages|default([])}}"
become: yes
-26
View File
@@ -1,26 +0,0 @@
---
# file: tasks/service.yml
- name: service - activate local (openrc)
service:
name: local
enabled: yes
when: hosts_enable_local|default(false) and ansible_service_mgr|lower == "openrc"
become: yes
- name: service - activate zram
service:
name: zram
state: started
enabled: yes
when: hosts_enable_zram|default(false) and ansible_service_mgr|lower != "openrc"
become: yes
- name: service - activate zram (openrc)
service:
name: zram-openrc
state: started
enabled: yes
runlevel: boot
when: hosts_enable_zram|default(false) and ansible_service_mgr|lower == "openrc"
become: yes
+22
View File
@@ -0,0 +1,22 @@
---
# file: tasks/services.yml
- name: services - enable/disable hosts services
when: ansible_service_mgr|lower != "openrc"
with_items: "{{ hosts_services|default([]) }}"
service:
name: "{{item.name}}"
state: "{{item.state}}"
enabled: "{{item.enabled}}"
become: yes
- name: services - openrc - enable/disable hosts services
when: ansible_service_mgr|lower == "openrc"
with_items: "{{ hosts_services|default([]) }}"
service:
name: "{{item.name}}"
state: "{{item.state}}"
enabled: "{{item.enabled}}"
runlevel: boot
become: yes
+10 -9
View File
@@ -7,8 +7,8 @@
path: /etc/ssh/ssh_known_hosts
name: "{{ item }}"
key: "{{ lookup('pipe', 'ssh-keyscan -t rsa -H ' + item) }}"
become: true
ignore_errors: true
become: true
- name: ssh - define sshd configuration
set_fact:
@@ -24,20 +24,21 @@
regex: ^#?PermitRootLogin
- name: ssh - stat sshd configuration file
changed_when: false
register: sshd_config_stat
with_items: "{{ sshd_config|default([]) }}"
stat:
path: "{{ item.dest }}"
with_items: "{{ sshd_config|default([]) }}"
changed_when: false
register: sshd_config_stat
- name: ssh - configure sshd
become: yes
when: item.1.stat.exists
with_together:
- "{{ sshd_config|default([]) }}"
- "{{ sshd_config_stat.results }}"
lineinfile:
backrefs: true
dest: "{{ item.0.dest }}"
line: "{{ item.0.line }}"
regex: "{{ item.0.regex }}"
with_together:
- "{{ sshd_config|default([]) }}"
- "{{ sshd_config_stat.results }}"
when: item.1.stat.exists
become: yes
+8 -12
View File
@@ -2,8 +2,8 @@
# file: tasks/user.yml
- name: user - add hosts_ssh_authorized_keys to ~/.ssh/authorized_keys
authorized_key: user="{{ ansible_user|default('root') }}" key="{{ item }}"
with_items: "{{ hosts_ssh_authorized_keys|default([]) }}"
authorized_key: user="{{ ansible_user|default('root') }}" key="{{ item }}"
ignore_errors: true
- name: user - copy hosts_ssh_private_keys to ~/.ssh/
@@ -19,23 +19,18 @@
mode: 0400
- name: user - create ~/.rc.d
file: path=~/.rc.d/ state={{hosts_enable_rc|default(false)|ternary('directory', 'absent')}} mode="0700"
file: path=~/.rc.d/ state={{hosts_user_rc_enable|default(false)|ternary('directory', 'absent')}} mode="0700"
- name: user - source /etc/profile.d/rc_functions.sh
when: hosts_user_rc_enable|default(false)
with_items:
- /etc/profile.d/rc_functions.sh
lineinfile: dest=~/.rc.d/00_source create=yes line="{{ item }}" mode="0600"
when: hosts_enable_rc|default(false)
- name: user - enable rc functions
with_items: "{{hosts_rc_functions|default([])}}"
file: path="~/.rc.d/{{item}}" state="touch" mode="0600"
when: hosts_enable_rc|default(false)
- name: user - disable rc functions
with_items: "{{hosts_rc_cleanup|default([])}}"
file: path="~/.rc.d/{{item}}" state="absent"
when: hosts_enable_rc|default(false)
- name: user - enable/disable rc functions
when: hosts_user_rc_enable|default(false)
with_items: "{{ hosts_user_rc_functions|default([]) }}"
file: path="~/.rc.d/{{item.path}}" state="{{item.state}}"
- name: user - copy ~/.*aliases ~/.*functions ~/.*profile ~/.shrc
with_items:
@@ -112,3 +107,4 @@
src: Makefile.j2
dest: ~/Makefile
force: yes
+1
View File
@@ -32,3 +32,4 @@
- files:
- "local.yml"
skip: true