浏览代码

Initial commit, needs service name as variable

Sven Velt 6 年之前
当前提交
6f93842670
共有 1 个文件被更改,包括 18 次插入0 次删除
  1. 18 0
      tasks/main.yml

+ 18 - 0
tasks/main.yml

@@ -0,0 +1,18 @@
+---
+- name: "Set «PermitRootLogin» to «without-password»"
+  lineinfile:
+    dest: /etc/ssh/sshd_config
+    regexp: '^#? *PermitRootLogin'
+    line: "PermitRootLogin without-password"
+    backup: yes
+  register: sshconfigchanged
+
+
+- name: Restart sshd
+  service:
+    name: "{{ ssh_service_name }}"
+    state: restarted
+    sleep: 5
+  when: sshconfigchanged is changed
+
+