initial control node playbook

This commit is contained in:
Ibrahim Mkusa 2024-09-01 16:26:50 -04:00
commit 4a24e7cdaf
5 changed files with 46 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
secrets.yml

3
ansible.cfg Normal file
View File

@ -0,0 +1,3 @@
[defaults]
inventory=./inventory
remote_user="pollen"

9
inventory Normal file
View File

@ -0,0 +1,9 @@
[aws]
aws ansible_user=ubuntu
[doc]
doc ansible_user=pollen
[servers:children]
doc
aws

View File

@ -0,0 +1,19 @@
---
- name: sets up the control node
hosts: localhost
vars_files:
- ../vars/secrets.yml
tasks:
- name: create the ansible control user
user:
name: ansible
generate_ssh_key: true
- name: Create the password for the control user
shell:
cmd: echo {{ become_password }} | passwd --stdin ansible
when: ansible_os_family == 'RedHat'
#when: ansible_facts['ansible_os_family'] == 'RedHat'
- name: install chpasswd on debian family os
shell:
cmd: echo ansible:{{ become_password }} | chpasswd
when: ansible_os_family == 'Debian'

View File

@ -0,0 +1,14 @@
---
- name: Updates all managed servers
hosts: all
become: true
vars:
group_vars: groups_vars/servers.yml
tasks:
- name: update package index on all machines
ansible.builtin.apt:
update_cache: yes
- name: Upgrade all packages to latest version
ansible.builtin.apt:
name: "*"
state: latest