Ansible Playbook - VBychkov-boop/Spring-SYS265-Final-Project GitHub Wiki
Making Ansible tasks
Within MGMT02, ping all devices to make sure MGMT02 is able to see them.
Make the Directory
`sudo mkdir -p /etc/ansible/playbooks
Put all Ansible playbooks into that directory
Ansible APT package
Make a new Ansible playbook
- name: Install apt package
hosts: dhcp01,dhcp02,util
become: yes
tasks:
- name: Install htop
apt:
name: htop
state: present
- Run this to run the playbook:
ansible-playbook /etc/ansible/playbooks/apt_install.yml --ask-become-pass
Yum Package
- Make the file
sudo nano /etc/ansible/playbooks/yum_install.yml
- Make the ansible file
- name: Install yum package
hosts: dhcp01,dhc02,util
become: yes
tasks:
- name: Install vim via yum
package:
name: vim
state: present
use: apt
- Run the playbook ansible command
ansible-playbook /etc/ansible/playbooks/yum_install.yml --ask-become-pass
Add a Linux local user
sudo nano /etc/ansible/playbooks/add_linux_user.yml
- name: Add Linux local user
hosts: dhcp01,dhcp02,util
become: yes
tasks:
- name: Create new user
user:
name: b1localuser
password: "{{ 'Password1!' | password_hash('sha512') }}"
shell: /bin/bash
create_home: yes
state: present
Continue to run as normal
ansible-playbook /etc/ansible/playbooks/add_linux_user.yml --ask-become-pass
Add Windows Domain user
sudo nano /etc/ansible/playbooks/add_windows_users.yml
- name: Add Windows domain user
hosts: dc01
tasks:
- name: Create domain user
win_domain_user:
name: b1domainuser
password: "Password1!"
state: present
enabled: yes
Testing
Testing b1local (Linux)
ssh b1local@dhcp01
Login with credentials
and it should be successful!
Testing Windows Domain user
Log into DC01 and Check through powershell:
Get-ADUser b1domainuser
And it will pop up successfully