migrate
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
[defaults]
|
||||
interpreter_python=auto_silent
|
||||
host_key_checking=False
|
||||
@@ -0,0 +1,29 @@
|
||||
---
|
||||
- name: Post install configuration
|
||||
hosts: all
|
||||
become: true # Use this if you need sudo privileges
|
||||
tasks:
|
||||
|
||||
- name: Update and Upgrade all packages
|
||||
apt:
|
||||
update_cache: yes
|
||||
upgrade: dist
|
||||
when: ansible_os_family == "Debian"
|
||||
|
||||
- name: create ansible user
|
||||
user:
|
||||
name: ansible
|
||||
shell: '/bin/bash'
|
||||
|
||||
- name: Install public keys
|
||||
authorized_key:
|
||||
user: ansible
|
||||
key: "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINxwwGO69n2Ljbip4h43T4SRgzRu6iaUPWXR/R25rPjr ansible@ubuntu03"
|
||||
|
||||
- name: add ansible to sudoers
|
||||
copy:
|
||||
src: sudoer_ansible
|
||||
dest: /etc/sudoers.d/ansible
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0440
|
||||
@@ -0,0 +1 @@
|
||||
ansible ALL=(ALL) NOPASSWD: ALL
|
||||
@@ -0,0 +1,19 @@
|
||||
[servers]
|
||||
192.168.2.1
|
||||
192.168.2.2
|
||||
192.168.2.3
|
||||
192.168.2.7
|
||||
192.168.2.8
|
||||
192.168.2.9
|
||||
192.168.2.10
|
||||
192.168.2.13
|
||||
192.168.2.14
|
||||
192.168.2.16
|
||||
#192.168.2.17
|
||||
#192.168.2.18
|
||||
192.168.2.19
|
||||
192.168.2.20
|
||||
192.168.2.22
|
||||
192.168.2.23
|
||||
192.168.2.24
|
||||
150.136.35.94
|
||||
@@ -0,0 +1,19 @@
|
||||
---
|
||||
- name: Add ssh key
|
||||
hosts: "{{ my_hosts | d([]) }}"
|
||||
become: true
|
||||
|
||||
tasks:
|
||||
- name: Install public keys
|
||||
ansible.posix.authorized_key:
|
||||
user: "{{ lookup('env', 'USER') }}"
|
||||
state: present
|
||||
key: "{{ lookup('file', '~/.ssh/id_rsa.pub') }}"
|
||||
|
||||
- name: Change sudoers file
|
||||
ansible.builtin.lineinfile:
|
||||
path: /etc/sudoers
|
||||
state: present
|
||||
regexp: '^%sudo'
|
||||
line: '%sudo ALL=(ALL) NOPASSWD: ALL'
|
||||
validate: /usr/sbin/visudo -cf %s
|
||||
Reference in New Issue
Block a user