From 9a10ee6c9d83a1dd9d8b5f7d9178220d76fc80d2 Mon Sep 17 00:00:00 2001 From: Cian Hatton Date: Tue, 6 Sep 2022 08:23:10 +0100 Subject: [PATCH] fixing lint issues --- playbooks/setup-linode.yml | 1 + roles/setup_hosted_services/tasks/main.yml | 20 ++++---- roles/setup_linode/defaults/main-vault.yml | 19 +++++--- roles/setup_linode/defaults/main.yml | 9 ++-- roles/setup_linode/meta/main.yml | 52 +++------------------ roles/setup_linode/tasks/main.yml | 32 +++++++------ roles/setup_mergerfs/meta/main.yml | 54 +++------------------- roles/setup_mergerfs/tasks/main.yml | 28 +++++------ roles/setup_portainer/tasks/main.yml | 7 ++- 9 files changed, 77 insertions(+), 145 deletions(-) diff --git a/playbooks/setup-linode.yml b/playbooks/setup-linode.yml index e6bf949..c9c9d67 100644 --- a/playbooks/setup-linode.yml +++ b/playbooks/setup-linode.yml @@ -1,3 +1,4 @@ +--- - hosts: localhost become: true roles: diff --git a/roles/setup_hosted_services/tasks/main.yml b/roles/setup_hosted_services/tasks/main.yml index 30b81da..3ed4d84 100644 --- a/roles/setup_hosted_services/tasks/main.yml +++ b/roles/setup_hosted_services/tasks/main.yml @@ -85,26 +85,26 @@ - name: Docker | Create required docker networks docker_network: - name: '{{item}}' + name: '{{ item }}' with_items: '{{ docker_networks }}' - name: Portainer | Update Stack when: container_deployment_mode == "portainer" chatton.portainer.portainer_stack: username: admin - password: '{{portainer.password}}' + password: '{{ portainer.password }}' docker_compose_file_path: '{{ directories.docker_compose_directory }}/{{ item.name }}/docker-compose.yml' stack_name: '{{ item.name }}' endpoint_id: '{{ item.endpoint_id }}' state: present - with_items: '{{services}}' + with_items: '{{ services }}' - name: Docker compose | Update Stack when: container_deployment_mode == "compose" docker_compose: - project_src: '{{directories.docker_compose_directory}}/{{ item.name }}' + project_src: '{{ directories.docker_compose_directory }}/{{ item.name }}' state: present - with_items: '{{services}}' + with_items: '{{ services }}' - name: Install Ansible pull @@ -122,7 +122,9 @@ minute: "*" hour: "4" user: "{{ homelab_user }}" - job: "/home/{{ homelab_user }}/.local/bin/ansible-pull -U https://github.com/chatton/ansible-homelab playbooks/backup-docker-volumes.yml -e schedule=nightly >> ~/logs/nightly.log 2>&1" + job: > + /home/{{ homelab_user }}/.local/bin/ansible-pull + -U https://github.com/chatton/ansible-homelab playbooks/backup-docker-volumes.yml -e schedule=nightly >> ~/logs/nightly.log 2>&1 cron_file: ansible_nightly_docker_volume_backup state: present @@ -131,8 +133,10 @@ ansible.builtin.cron: name: backup docker volumes (monthly) month: "*" - day : "1" + day: "1" user: "{{ homelab_user }}" - job: "/home/{{ homelab_user }}/.local/bin/ansible-pull -U https://github.com/chatton/ansible-homelab playbooks/backup-docker-volumes.yml -e schedule=monthly >> ~/logs/monthly.log 2>&1" + job: > + /home/{{ homelab_user }}/.local/bin/ansible-pull + -U https://github.com/chatton/ansible-homelab playbooks/backup-docker-volumes.yml -e schedule=monthly >> ~/logs/monthly.log 2>&1 cron_file: ansible_monthly_docker_volume_backup state: present diff --git a/roles/setup_linode/defaults/main-vault.yml b/roles/setup_linode/defaults/main-vault.yml index 0e19475..c261bc0 100644 --- a/roles/setup_linode/defaults/main-vault.yml +++ b/roles/setup_linode/defaults/main-vault.yml @@ -1,7 +1,12 @@ -$ANSIBLE_VAULT;1.1;AES256 36356161663039666634393933383830653035633438343866643730303434353632383031303965 -3465343332353437616663643662343262373333366162300a373662386533363234636234633339 35383439373430656130353938653531636563663066646265643838323230356231333836326262 -6439626538643837390a383039373366626637333738386332356361306131323133383534323462 32376564376363663666383639313064316365353037356633363035373632313561643030643933 -34663533313231636162306465656433663634643038343938396462643261656238626432633136 39356562353463353034373534386537313634326534623830616362336638396337386631663538 -30663236653532316461306636333536373836626537363430613961346137626261333238366234 30633438653936316539326436393634366236616664383835396434373966333166366265636661 -39666335653265323565313831303264336331363339333532353939653330383362363965353032 383434386133323961373833303262336439 -... +$ANSIBLE_VAULT;1.1;AES256 +38343033383061343739363362626366376630376337376639376235316665363736376362633830 +6638383135303063363866623262303736393337386364630a353533323537376437343033666334 +32353832353466343832643238313834616662333736363738353565623063316438393635343631 +6662366132396337320a326335353333306262666561353037356539633432376439666133386463 +30326230316634346431346266333030303435313065616665656362663164313638313639313633 +63343538653230653330383336386138643636333361326139346336646665366530343537663331 +61303639313335343162613838303034616362303935653862666166656634613562376330306165 +32373832666438623638616363363931636664633337396336653237356234616438623261353134 +62373463313235323233343734363561353237613439663534393537333964323932373837356564 +32383536613332323532633534306632373762666236366664383636323264363433396437666437 +323637336362613139633237316237666365 diff --git a/roles/setup_linode/defaults/main.yml b/roles/setup_linode/defaults/main.yml index 0be9da5..fc6d822 100644 --- a/roles/setup_linode/defaults/main.yml +++ b/roles/setup_linode/defaults/main.yml @@ -1,12 +1,11 @@ -# defaults file for setup_linode ssh_keys: -- "{{ lookup('file', '~/.ssh/id_rsa.pub') }}" + - "{{ lookup('file', '~/.ssh/id_rsa.pub') }}" label: simple-linode # hosts that are added to the generated .ini file. -hosts: -- user: root - ip: '{{my_linode.instance.ipv4[0]}}' +linode_hosts: + - user: root + ip: '{{ my_linode.instance.ipv4[0] }}' # https://www.linode.com/community/questions/17190/obtain-a-list-of-image-and-plan-types-using-linode-apicli type: g6-standard-2 diff --git a/roles/setup_linode/meta/main.yml b/roles/setup_linode/meta/main.yml index 6bfa85e..d30c169 100644 --- a/roles/setup_linode/meta/main.yml +++ b/roles/setup_linode/meta/main.yml @@ -1,53 +1,13 @@ galaxy_info: author: Cian Hatton namespace: chatton - description: your role description - company: your company (optional) - - # If the issue tracker for your role is not on github, uncomment the - # next line and provide a value - # issue_tracker_url: http://example.com/issue/tracker - - # Choose a valid license ID from https://spdx.org - some suggested licenses: - # - BSD-3-Clause (default) - # - MIT - # - GPL-2.0-or-later - # - GPL-3.0-only - # - Apache-2.0 - # - CC-BY-4.0 + description: Setup Linode instance license: MIT - min_ansible_version: 2.1 - - # If this a Container Enabled role, provide the minimum Ansible Container version. - # min_ansible_container_version: - - # - # Provide a list of supported platforms, and for each platform a list of versions. - # If you don't wish to enumerate all versions for a particular platform, use 'all'. - # To view available platforms and versions (or releases), visit: - # https://galaxy.ansible.com/api/v1/platforms/ - # - # platforms: - # - name: Fedora - # versions: - # - all - # - 25 - # - name: SomePlatform - # versions: - # - all - # - 1.0 - # - 7 - # - 99.99 - + min_ansible_version: "2.1" + platforms: + - name: Debian + versions: + - all galaxy_tags: [] - # List tags for your role here, one per line. A tag is a keyword that describes - # and categorizes the role. Users find roles by searching for tags. Be sure to - # remove the '[]' above, if you add tags to this list. - # - # NOTE: A tag is limited to a single word comprised of alphanumeric characters. - # Maximum 20 tags per role. - dependencies: [] - # List your role dependencies here, one per line. Be sure to remove the '[]' above, - # if you add dependencies to this list. diff --git a/roles/setup_linode/tasks/main.yml b/roles/setup_linode/tasks/main.yml index cbfd1f8..81e2cfc 100644 --- a/roles/setup_linode/tasks/main.yml +++ b/roles/setup_linode/tasks/main.yml @@ -1,5 +1,6 @@ +--- - name: Include vault variables. - include_vars: defaults/main-vault.yml + ansible.builtin.include_vars: defaults/main-vault.yml - name: Create a new Linode. linode_v4: @@ -15,19 +16,22 @@ register: my_linode - name: Wait for SSH to come up - local_action: - module: wait_for host={{ my_linode.instance.ipv4[0] }} port=22 search_regex=OpenSSH - timeout=320 + delegate_to: localhost + ansible.builtin.wait_for: + host: "{{ my_linode.instance.ipv4[0] }}" + port: 22 + search_regex: OpenSSH + timeout: 320 - name: Instance Details - debug: - msg: '{{my_linode}}' + ansible.builtin.debug: + msg: '{{ my_linode }}' -- name: Update hosts.ini - blockinfile: - path: hosts.ini - block: | - [linode] - {% for host in hosts %} - {{host.user}}@{{host.ip}} - {% endfor %} +# - name: Update hosts.ini +# blockinfile: +# path: hosts.ini +# block: | +# [linode] +# {% for host in linode_hosts %} +# {{ host.user }}@{{ host.ip }} +# {% endfor %} diff --git a/roles/setup_mergerfs/meta/main.yml b/roles/setup_mergerfs/meta/main.yml index 6bfa85e..853fff9 100644 --- a/roles/setup_mergerfs/meta/main.yml +++ b/roles/setup_mergerfs/meta/main.yml @@ -1,53 +1,11 @@ galaxy_info: author: Cian Hatton namespace: chatton - description: your role description - company: your company (optional) - - # If the issue tracker for your role is not on github, uncomment the - # next line and provide a value - # issue_tracker_url: http://example.com/issue/tracker - - # Choose a valid license ID from https://spdx.org - some suggested licenses: - # - BSD-3-Clause (default) - # - MIT - # - GPL-2.0-or-later - # - GPL-3.0-only - # - Apache-2.0 - # - CC-BY-4.0 + description: Configures Mergerfs license: MIT - - min_ansible_version: 2.1 - - # If this a Container Enabled role, provide the minimum Ansible Container version. - # min_ansible_container_version: - - # - # Provide a list of supported platforms, and for each platform a list of versions. - # If you don't wish to enumerate all versions for a particular platform, use 'all'. - # To view available platforms and versions (or releases), visit: - # https://galaxy.ansible.com/api/v1/platforms/ - # - # platforms: - # - name: Fedora - # versions: - # - all - # - 25 - # - name: SomePlatform - # versions: - # - all - # - 1.0 - # - 7 - # - 99.99 - - galaxy_tags: [] - # List tags for your role here, one per line. A tag is a keyword that describes - # and categorizes the role. Users find roles by searching for tags. Be sure to - # remove the '[]' above, if you add tags to this list. - # - # NOTE: A tag is limited to a single word comprised of alphanumeric characters. - # Maximum 20 tags per role. - + min_ansible_version: "2.1" + platforms: + - name: Debian + versions: + - all dependencies: [] - # List your role dependencies here, one per line. Be sure to remove the '[]' above, - # if you add dependencies to this list. diff --git a/roles/setup_mergerfs/tasks/main.yml b/roles/setup_mergerfs/tasks/main.yml index 08dcd2a..ebca19f 100644 --- a/roles/setup_mergerfs/tasks/main.yml +++ b/roles/setup_mergerfs/tasks/main.yml @@ -1,26 +1,22 @@ -# dangerous to use this as the device name changes when there are new drives. -# can this be done with an ID? -#- name: Create a ext4 filesystem on /dev/sdb1 -# filesystem: -# fstype: ext4 -# dev: /dev/sdb1 -# state: present - +--- - name: Mount Volumes - mount: - path: '{{item.path}}' - src: UUID={{item.uuid}} + ansible.builtin.mount: + path: '{{ item.path }}' + src: UUID={{ item.uuid }} fstype: ext4 state: mounted opts: defaults,nofail loop: '{{ devices }}' register: volume_out -- debug: msg="{{volume_out}}" +- name: Display volumes. + ansible.builtin.debug: + var: "{{ volume_out }}" + verbosity: 3 # tasks file for setup_mergerfs - name: Create Mergerfs directory - file: + ansible.builtin.file: path: /mnt/mergerfs state: directory owner: cianhatton @@ -30,11 +26,11 @@ # Ensure the actual folder can't be written to only when it has just been created. - name: Make /mnt/mergerfs immutable - command: chattr +i /mnt/mergerfs - when: directory_creation.changed == true + ansible.builtin.command: chattr +i /mnt/mergerfs + when: directory_creation.diff.after.path != directory_creation.diff.before.path - name: Create Mergerfs pool - include_role: + ansible.builtin.include_role: name: sprat.mergerfs vars: mergerfs_mounts: '{{ mounts }}' diff --git a/roles/setup_portainer/tasks/main.yml b/roles/setup_portainer/tasks/main.yml index cfebbb7..fe3560e 100644 --- a/roles/setup_portainer/tasks/main.yml +++ b/roles/setup_portainer/tasks/main.yml @@ -3,12 +3,17 @@ ansible.builtin.file: path: '{{ directories.docker_compose_directory }}' state: directory - mode: '0755' + owner: root + group: root + mode: 0440 - name: Portainer | Copy docker compose file. ansible.builtin.copy: src: docker-compose.yml dest: '{{ directories.docker_compose_directory }}/docker-compose.yml' + owner: root + group: root + mode: 0440 - name: Portainer | Check if volume exists ansible.builtin.shell: docker volume ls -f name=portainer_portainer_data --format '{{ '{{' }} .Name {{ '}}' }}'