diff --git a/.vscode/settings.json b/.vscode/settings.json index a2a478d..9b2da51 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,9 @@ { - "ansible.python.interpreterPath": "c:\\Users\\keannu125\\AppData\\Local\\Programs\\Python\\Python311\\python.exe" + "ansible.python.interpreterPath": "c:\\Users\\keannu125\\AppData\\Local\\Programs\\Python\\Python311\\python.exe", + "yaml.schemas": { + "https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/ansible.json#/$defs/playbook": [ + "file:///e%3A/Projects/AnsibleTest/setup.yml", + "file:///e%3A/Projects/AnsibleTest/update.yml" + ] + } } diff --git a/README.md b/README.md index 76d1b5a..5d13213 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ This repository contains my Ansible playbook configuration and scripts. To install the Ansible playbook, follow these steps: -1. Clone this repository using `git clone ` +1. Clone this repository 2. Install Ansible on your system if you haven't already: `sudo apt-get install ansible` 3. Move into the repository directory: `cd /path/to/ansible-playbooks` @@ -15,5 +15,7 @@ To install the Ansible playbook, follow these steps: To run an Ansible playbook, navigate to the desired playbook directory and execute: ```bash -ansible-playbook -i inventory.ini playbook.yml +ansible-playbook -i inventory playbook.yml ``` + +Don't forget to update hosts in `inventory`! diff --git a/setup.yml b/setup.yml index 5c341aa..812e9d3 100644 --- a/setup.yml +++ b/setup.yml @@ -3,18 +3,19 @@ # Runs on root user already become: false tasks: - - name: Add SSH key to authorized_hosts + - name: Add SSH key to authorized_hosts - Debian/Ubuntu authorized_key: user: root state: present key: "{{ lookup('file', '~/.ssh/id_rsa.pub') }}" path: /root/.ssh/authorized_keys + when: ansible_distribution in ["Debian", "Ubuntu"] - name: Update all packages apt: update_cache: true autoremove: true state: latest - - name: Install packages + - name: Install packages - Debian/Ubuntu apt: name: - vim @@ -27,8 +28,10 @@ - neofetch - cifs-utils - curl + # Cache is already updated from previous step update_cache: false autoremove: true state: latest + when: ansible_distribution in ["Debian", "Ubuntu"] - name: Install ACME command: curl https://get.acme.sh | sh -s email=noehbernasol0@gmail.com diff --git a/update.yml b/update.yml index 2dd0711..707ed69 100644 --- a/update.yml +++ b/update.yml @@ -8,5 +8,7 @@ update_cache: true autoremove: true state: latest + when: ansible_distribution in ["Debian", "Ubuntu"] - name: Update ACME command: /root/.acme.sh/acme.sh --upgrade --auto-upgrade + when: ansible_distribution in ["Debian", "Ubuntu"]