diff --git a/.config/ansible-lint.yml b/.config/ansible-lint.yml new file mode 100644 index 0000000..6354f19 --- /dev/null +++ b/.config/ansible-lint.yml @@ -0,0 +1,9 @@ +skip_list: + - yaml[indentation] + + # TODO I probably want these to be correct + - meta-no-info + - meta-incorrect + - schema + - fqcn-builtins + - schema diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 9a77cad..3cf1642 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -25,3 +25,16 @@ jobs: - name: Test Directory run: ansible-lint ${{ matrix.directory }} + format: + runs-on: ubuntu-latest + steps: + - name: Checkout the codebase + uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: 3.8.9 + - name: Install dependencies + run: make deps + - name: Format code + run: make format + diff --git a/Makefile b/Makefile index 53d93b3..1f72807 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ bootstrap: qnap: ansible-playbook playbooks/setup-homelab.yml --limit qnap -homelab: +homelab: bootstrap ansible-playbook playbooks/setup-homelab.yml verify: diff --git a/roles/setup_docker/tasks/main.yml b/roles/setup_docker/tasks/main.yml index 89345af..d4a9895 100644 --- a/roles/setup_docker/tasks/main.yml +++ b/roles/setup_docker/tasks/main.yml @@ -15,7 +15,7 @@ - lsb-release - pip state: present - update_cache: yes + update_cache: true - name: Add Docker GPG apt Key apt_key: @@ -36,7 +36,7 @@ - containerd.io - docker-compose-plugin state: present - update_cache: yes + update_cache: true - name: Install Docker Module for Python pip: diff --git a/roles/setup_hosted_services/handlers/main.yml b/roles/setup_hosted_services/handlers/main.yml index 61ecc28..9d69602 100644 --- a/roles/setup_hosted_services/handlers/main.yml +++ b/roles/setup_hosted_services/handlers/main.yml @@ -1,10 +1,10 @@ # handlers file for setup_hosted_services - name: restart-dashy - shell: docker restart dashy + command: docker restart dashy ignore_errors: true - name: restart-olivetin - shell: docker restart olivetin + command: docker restart olivetin - name: restart-docker-volume-backup - shell: docker restart docker-volume-backup + command: docker restart docker-volume-backup diff --git a/roles/setup_samba/tasks/main.yml b/roles/setup_samba/tasks/main.yml index de03b3f..04f9c57 100644 --- a/roles/setup_samba/tasks/main.yml +++ b/roles/setup_samba/tasks/main.yml @@ -3,7 +3,7 @@ name: - samba state: present - update_cache: yes + update_cache: true - name: Ensure samba group exists ansible.builtin.group: @@ -27,13 +27,13 @@ user: name: '{{ item.name }}' groups: '{{ samba_group }}' - append: yes + append: true with_items: '{{users}}' - name: Ensure Share directories ansible.builtin.file: path: '{{item}}' - recurse: yes + recurse: true state: directory owner: '{{samba_user}}' group: '{{samba_group}}' diff --git a/roles/setup_users/tasks/main.yml b/roles/setup_users/tasks/main.yml index 35d4a9f..a2d0f63 100644 --- a/roles/setup_users/tasks/main.yml +++ b/roles/setup_users/tasks/main.yml @@ -8,26 +8,27 @@ - name: Make sure we have a groups group: - name: '{{item.group}}' + name: '{{ item.group }}' state: present - with_items: '{{users}}' + with_items: '{{ users }}' - name: Add Users ansible.builtin.user: - name: '{{item.name}}' - comment: '{{item.name}} user' - group: '{{item.group}}' - with_items: '{{users}}' + name: '{{ item.name }}' + comment: '{{ item.name }} user' + group: '{{ item.group }}' + with_items: '{{ users }}' - name: Add sudoers template: src: sudoers.j2 dest: /etc/sudoers.d/{{item.name}} - with_items: '{{users}}' + mode: 0440 + with_items: '{{ users }}' when: item.passwordless_sudo == true - name: Set authorized key authorized_key: - user: '{{homelab_user}}' + user: '{{ homelab_user }}' state: present key: "{{ lookup('file', '~/.ssh/id_rsa.pub') }}"