From fd5c3acb950c194b9a12a10b73944d68940e9c69 Mon Sep 17 00:00:00 2001 From: nazunalika Date: Fri, 3 Jun 2022 19:56:40 -0700 Subject: [PATCH] Add a tmp folder for init --- .gitignore | 1 + init-ansible-host.yml | 46 +++++++++++++++++++++++++++ roles/{roles.yml => requirements.yml} | 0 tmp/tmp | 0 4 files changed, 47 insertions(+) create mode 100644 .gitignore create mode 100644 init-ansible-host.yml rename roles/{roles.yml => requirements.yml} (100%) create mode 100644 tmp/tmp diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bb8ca25 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +ansible.cfg diff --git a/init-ansible-host.yml b/init-ansible-host.yml new file mode 100644 index 0000000..9d569ad --- /dev/null +++ b/init-ansible-host.yml @@ -0,0 +1,46 @@ +--- +# 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 + file: + path: "{{ installation_prefix }}{{ roles_installation_dir }}" + state: absent + when: force_purge | bool + + - name: Install all public roles and collections + command: > + 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 + command: > + 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 + file: + path: "./tmp/known_hosts" + state: absent + mode: "0644" + + - name: cleanup old ssh known_hosts - blank + file: + path: "./tmp/known_hosts" + state: touch + mode: "0644" +... diff --git a/roles/roles.yml b/roles/requirements.yml similarity index 100% rename from roles/roles.yml rename to roles/requirements.yml diff --git a/tmp/tmp b/tmp/tmp new file mode 100644 index 0000000..e69de29