ansible-gitea-management/init-ansible-host.yml

47 lines
1.6 KiB
YAML
Raw Normal View History

2022-06-04 02:56:40 +00:00
---
# YOU SHOULD ONLY RUN THIS IF YOU ARE USING THIS LOCALLY. DO NOT RUN IN AWX.
- hosts: localhost
connection: local
vars:
force_purge: true
roles_installation_dir: roles/public
collection_installation_dir: collections
installation_prefix: ./
pre_tasks:
- name: Remove existing public roles
2022-11-08 22:20:17 +00:00
ansible.builtin.file:
2022-06-04 02:56:40 +00:00
path: "{{ installation_prefix }}{{ roles_installation_dir }}"
state: absent
when: force_purge | bool
- name: Install all public roles and collections
2022-11-08 22:20:17 +00:00
ansible.builtin.command: >
2022-06-04 02:56:40 +00:00
ansible-galaxy role install
{{ ( force_purge | bool ) | ternary('--force','') }}
--role-file {{ installation_prefix }}roles/requirements.yml
--roles-path {{ installation_prefix }}{{ roles_installation_dir }}
register: galaxy_install_role
changed_when: '"Installing " in galaxy_install_role.stdout'
- name: Install needed collections
2022-11-08 22:20:17 +00:00
ansible.builtin.command: >
2022-06-04 02:56:40 +00:00
ansible-galaxy collection install
{{ ( force_purge | bool ) | ternary('--force-with-deps','') }}
-r {{ installation_prefix }}collections/requirements.yml
-p {{ installation_prefix }}{{ collection_installation_dir }}
register: galaxy_install_collection
changed_when: '"Installing " in galaxy_install_collection.stdout'
- name: cleanup old ssh known_hosts - remove
2022-11-08 22:20:17 +00:00
ansible.builtin.file:
2022-06-04 02:56:40 +00:00
path: "./tmp/known_hosts"
state: absent
mode: "0644"
- name: cleanup old ssh known_hosts - blank
2022-11-08 22:20:17 +00:00
ansible.builtin.file:
2022-06-04 02:56:40 +00:00
path: "./tmp/known_hosts"
state: touch
mode: "0644"
...