commit 4a24e7cdafc0a7fe46aabbe855e54b8b4cfa36cc Author: Ibrahim Mkusa Date: Sun Sep 1 16:26:50 2024 -0400 initial control node playbook diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..769c244 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +secrets.yml diff --git a/ansible.cfg b/ansible.cfg new file mode 100644 index 0000000..5e7e922 --- /dev/null +++ b/ansible.cfg @@ -0,0 +1,3 @@ +[defaults] +inventory=./inventory +remote_user="pollen" diff --git a/inventory b/inventory new file mode 100644 index 0000000..6aec0eb --- /dev/null +++ b/inventory @@ -0,0 +1,9 @@ +[aws] +aws ansible_user=ubuntu + +[doc] +doc ansible_user=pollen + +[servers:children] +doc +aws diff --git a/playbooks/control_node.yml b/playbooks/control_node.yml new file mode 100644 index 0000000..4896a0e --- /dev/null +++ b/playbooks/control_node.yml @@ -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' diff --git a/playbooks/update_upgrade.yml b/playbooks/update_upgrade.yml new file mode 100644 index 0000000..6aad2bb --- /dev/null +++ b/playbooks/update_upgrade.yml @@ -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