From 35ece6c9ce3e03e436bff058879e29d5d23da68d Mon Sep 17 00:00:00 2001 From: James Hackett Date: Wed, 30 Nov 2022 22:50:08 +0000 Subject: [PATCH] adds base playbook and updates README --- README.md | 9 +++++++-- ansible/redbrick-ansible.yml | 8 ++++++++ ansible/roles/apt/tasks/main.yml | 11 +++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 ansible/redbrick-ansible.yml diff --git a/README.md b/README.md index 6a63eb3..9fc49e7 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,12 @@ This will plan and run the job file without the need for you to copy and paste t Ansible can be used to provision a new host, connect a host to the cluster, run new jobs and more. -In order to use ansible from your local machine, you must have access to the admin vpn. This will allow you direct connection to each of the hosts. +Install ansible from [here](https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html). -Change the `ansible/hosts.sample` file to your local username before you run any of these playbooks. Your local user should have an SSH key in its home dir, which can be configured with the `ssh` playbook. +In order to use ansible from your local machine, you must have access to the admin VPN. This will allow you direct connection to each of the hosts. +Move the `ansible/group_vars/all.yml.sample` file to `ansible/group_vars/all.yml` and change your local username before you run any of these playbooks. Your local user should have an SSH key in its home dir, which can be configured with the `ssh` playbook. + +```bash +$ ansible-playbook -i hosts redbrick-ansible.yml +``` diff --git a/ansible/redbrick-ansible.yml b/ansible/redbrick-ansible.yml new file mode 100644 index 0000000..e60672f --- /dev/null +++ b/ansible/redbrick-ansible.yml @@ -0,0 +1,8 @@ +--- + +- name: Redbrick Nomad, Consul and general management + hosts: all + gather_facts: true + roles: + - { role: apt } # update all packages, equivalent to `apt update && apt upgrade` + - { role: ssh } # add users defined in roles/defaults/main.yml diff --git a/ansible/roles/apt/tasks/main.yml b/ansible/roles/apt/tasks/main.yml index 556ca23..d1cbe0d 100644 --- a/ansible/roles/apt/tasks/main.yml +++ b/ansible/roles/apt/tasks/main.yml @@ -3,8 +3,19 @@ become: true apt: upgrade: yes + autoclean: yes + autoremove: yes update_cache: yes when: ansible_os_family == "Debian" and apt_update_packages + register: result + +- name: List installed and updated packages + shell: + cmd: 'grep -E "^$(date +%Y-%m-%d).+ (install|upgrade) " /var/log/dpkg.log | cut -d " " -f 3-5' + register: result + +- name: Show Output + debug: msg= '{{ result.stdout_lines }}' - name: install common tools ansible.builtin.apt: