commit 74fe532aa25d74da9ab489f9538c582a44d5b6ed Author: rcordier Date: Mon May 27 17:09:52 2024 -0400 add: initial files for domac diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1377554 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.swp diff --git a/Taskfile.yml b/Taskfile.yml new file mode 100644 index 0000000..2b01c2c --- /dev/null +++ b/Taskfile.yml @@ -0,0 +1,19 @@ +version: 3 + +tasks: + + install_deps: + desc: Install galaxy requirements + cmds: + - ansible-galaxy install -r requirements.yml + + run: + desc: Run site playbook + cmds: + - ansible-playbook playbooks/hello.yml + + inventory: + desc: show inventyory + aliases: [inv] + cmds: + - ansible-inventory --graph diff --git a/ansible.cfg b/ansible.cfg new file mode 100644 index 0000000..e08f79c --- /dev/null +++ b/ansible.cfg @@ -0,0 +1,11 @@ + + + +[defaults] +collections_path = ansible_collections/ + +inventory = inventories + +# For development only +# host_key_checking = False + diff --git a/ansible_collections/activia/infra_common b/ansible_collections/activia/infra_common new file mode 120000 index 0000000..89ca554 --- /dev/null +++ b/ansible_collections/activia/infra_common @@ -0,0 +1 @@ +../../../ansible-collection-infra-common/ \ No newline at end of file diff --git a/ansible_collections/activia/infra_common_RAW/FILES.json b/ansible_collections/activia/infra_common_RAW/FILES.json new file mode 100644 index 0000000..25bd86e --- /dev/null +++ b/ansible_collections/activia/infra_common_RAW/FILES.json @@ -0,0 +1,96 @@ +{ + "files": [ + { + "name": ".", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "roles", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "roles/configure_web", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "roles/configure_web/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "roles/configure_web/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "a7f5e5634a46103e9b70538ca016d12a53752b60c10055229f13049e6feb61a5", + "format": 1 + }, + { + "name": "roles/configure_db", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "roles/configure_db/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "roles/configure_db/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "15a8f838a77ee3d7666611b17a1b854bfc29d7a0e90fd473a2c0532fb7134970", + "format": 1 + }, + { + "name": "meta", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "meta/runtime.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "7b1d88aa041500f5b4a36c20a58adf116fbb48af9b5aa3be93949bd12cdae9dd", + "format": 1 + }, + { + "name": "README.md", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e893bf2c512f6c1962e6af28c91c042396eb14f097b11306968629760193b70d", + "format": 1 + }, + { + "name": "plugins", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/README.md", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "198c518c26e91bc01c3d50d163582796f2fa21c7b66a5581394b031469942d72", + "format": 1 + } + ], + "format": 1 +} \ No newline at end of file diff --git a/ansible_collections/activia/infra_common_RAW/MANIFEST.json b/ansible_collections/activia/infra_common_RAW/MANIFEST.json new file mode 100644 index 0000000..89b0757 --- /dev/null +++ b/ansible_collections/activia/infra_common_RAW/MANIFEST.json @@ -0,0 +1,30 @@ +{ + "collection_info": { + "namespace": "activia", + "name": "infra_common", + "version": "1.0.0", + "authors": [ + "your name " + ], + "readme": "README.md", + "tags": [], + "description": "your collection description", + "license": [ + "GPL-2.0-or-later" + ], + "license_file": null, + "dependencies": {}, + "repository": "http://example.com/repository", + "documentation": "http://docs.example.com", + "homepage": "http://example.com", + "issues": "http://example.com/issue/tracker" + }, + "file_manifest_file": { + "name": "FILES.json", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "61968d0a6bfe6ef4a2c778eca2be434ca326a253910a4fbe49e7a6292de6ee01", + "format": 1 + }, + "format": 1 +} \ No newline at end of file diff --git a/ansible_collections/activia/infra_common_RAW/README.md b/ansible_collections/activia/infra_common_RAW/README.md new file mode 100644 index 0000000..9641ba6 --- /dev/null +++ b/ansible_collections/activia/infra_common_RAW/README.md @@ -0,0 +1,3 @@ +# Ansible Collection - activia.infra_common + +Documentation for the collection. diff --git a/ansible_collections/activia/infra_common_RAW/meta/runtime.yml b/ansible_collections/activia/infra_common_RAW/meta/runtime.yml new file mode 100644 index 0000000..20f709e --- /dev/null +++ b/ansible_collections/activia/infra_common_RAW/meta/runtime.yml @@ -0,0 +1,52 @@ +--- +# Collections must specify a minimum required ansible version to upload +# to galaxy +# requires_ansible: '>=2.9.10' + +# Content that Ansible needs to load from another location or that has +# been deprecated/removed +# plugin_routing: +# action: +# redirected_plugin_name: +# redirect: ns.col.new_location +# deprecated_plugin_name: +# deprecation: +# removal_version: "4.0.0" +# warning_text: | +# See the porting guide on how to update your playbook to +# use ns.col.another_plugin instead. +# removed_plugin_name: +# tombstone: +# removal_version: "2.0.0" +# warning_text: | +# See the porting guide on how to update your playbook to +# use ns.col.another_plugin instead. +# become: +# cache: +# callback: +# cliconf: +# connection: +# doc_fragments: +# filter: +# httpapi: +# inventory: +# lookup: +# module_utils: +# modules: +# netconf: +# shell: +# strategy: +# terminal: +# test: +# vars: + +# Python import statements that Ansible needs to load from another location +# import_redirection: +# ansible_collections.ns.col.plugins.module_utils.old_location: +# redirect: ansible_collections.ns.col.plugins.module_utils.new_location + +# Groups of actions/modules that take a common set of options +# action_groups: +# group_name: +# - module1 +# - module2 diff --git a/ansible_collections/activia/infra_common_RAW/plugins/README.md b/ansible_collections/activia/infra_common_RAW/plugins/README.md new file mode 100644 index 0000000..67a66d4 --- /dev/null +++ b/ansible_collections/activia/infra_common_RAW/plugins/README.md @@ -0,0 +1,31 @@ +# Collections Plugins Directory + +This directory can be used to ship various plugins inside an Ansible collection. Each plugin is placed in a folder that +is named after the type of plugin it is in. It can also include the `module_utils` and `modules` directory that +would contain module utils and modules respectively. + +Here is an example directory of the majority of plugins currently supported by Ansible: + +``` +└── plugins + ├── action + ├── become + ├── cache + ├── callback + ├── cliconf + ├── connection + ├── filter + ├── httpapi + ├── inventory + ├── lookup + ├── module_utils + ├── modules + ├── netconf + ├── shell + ├── strategy + ├── terminal + ├── test + └── vars +``` + +A full list of plugin types can be found at [Working With Plugins](https://docs.ansible.com/ansible-core/2.16/plugins/plugins.html). diff --git a/ansible_collections/activia/infra_common_RAW/roles/configure_db/tasks/main.yml b/ansible_collections/activia/infra_common_RAW/roles/configure_db/tasks/main.yml new file mode 100644 index 0000000..4bcf9b3 --- /dev/null +++ b/ansible_collections/activia/infra_common_RAW/roles/configure_db/tasks/main.yml @@ -0,0 +1,4 @@ + +- name: This task configure the DB server + debug: + msg: The DB server has been configured diff --git a/ansible_collections/activia/infra_common_RAW/roles/configure_web/tasks/main.yml b/ansible_collections/activia/infra_common_RAW/roles/configure_web/tasks/main.yml new file mode 100644 index 0000000..3731cf3 --- /dev/null +++ b/ansible_collections/activia/infra_common_RAW/roles/configure_web/tasks/main.yml @@ -0,0 +1,4 @@ + +- name: This task configure the web server + debug: + msg: The WEB server has been configured diff --git a/inventories/00-common.yml b/inventories/00-common.yml new file mode 100644 index 0000000..225d477 --- /dev/null +++ b/inventories/00-common.yml @@ -0,0 +1,11 @@ +all: + children: + env: + # Place your environment here + roles: + # Place role mapping here + children: + role_web: + vars: + app_domain: "domain.{{ top_domain }}" + role_db: diff --git a/inventories/fake/hosts.yml b/inventories/fake/hosts.yml new file mode 100644 index 0000000..8f262cc --- /dev/null +++ b/inventories/fake/hosts.yml @@ -0,0 +1,25 @@ +env_fake: + hosts: + local: + fake-domac-web1: + fake-domac-web2: + fake-domac-db: + vars: + ansible_host: localhost + ansible_connection: local + environment_name: fake + +roles: + children: + role_web: + hosts: + fake-domac-web1: + fake-domac-web2: + #vars: + # ansible_user: root + role_db: + hosts: + fake-domac-db: + #vars: + # ansible_become: true + # ansible_become_pass: password diff --git a/inventories/lab/hosts.yml b/inventories/lab/hosts.yml new file mode 100644 index 0000000..5cade80 --- /dev/null +++ b/inventories/lab/hosts.yml @@ -0,0 +1,21 @@ +--- +env_lab: + hosts: + rocky-1: + ansible_host: 192.168.122.222 + rocky-2: + ansible_host: 192.168.122.96 + vars: + ansible_user: cloud-user + environment_name: lab + +# Inject roles +roles: + children: + role_web: + hosts: + rocky-1: + role_db: + hosts: + rocky-2: + diff --git a/inventories/rob/toto.yml b/inventories/rob/toto.yml new file mode 100644 index 0000000..85bcc06 --- /dev/null +++ b/inventories/rob/toto.yml @@ -0,0 +1,30 @@ +--- +env_rob: + hosts: + rocky-1: + ansible_host: 192.168.122.87 + rocky-2: + ansible_host: 1.2.3.4 + rocky-3: + ansible_host: 192.168.122.229 + vars: + ansible_user: cloud-user + environment_name: rob + +# Inject roles +roles: + children: + role_web: + vars: + app_domain: titi.activia.cim + hosts: + rocky-1: + role_db: + hosts: + rocky-1: + role_admin: + vars: + app_domain: admin.activia.cim + hosts: + rocky-1: + diff --git a/inventories/zz-constructed.yml b/inventories/zz-constructed.yml new file mode 100644 index 0000000..b327029 --- /dev/null +++ b/inventories/zz-constructed.yml @@ -0,0 +1,13 @@ +# inventory.config file in YAML format +# Documentation: ansible-doc -t inventory ansible.builtin.constructed +# +# Reproduce AWX behavior for constructed inventories + +plugin: ansible.builtin.constructed +strict: False + +keyed_groups: + - prefix: env + key: environment_name + parent_group: env + diff --git a/playbooks/hello.yml b/playbooks/hello.yml new file mode 100644 index 0000000..e0695d9 --- /dev/null +++ b/playbooks/hello.yml @@ -0,0 +1,53 @@ + + +- name: Hello World + hosts: localhost + gather_facts: no + + pre_tasks: + - name: Print debug message v1 + debug: + msg: Hello, world! + - name: Show groups + debug: + var: groups + - name: get debug infos + shell: + cmd: |- + ansible-galaxy collection list || true + register: output1 + + - name: Show collections + debug: + var: output1 + - name: get debug infos + shell: + cmd: |- + echo ID=$(id -u) + echo PWD=$PWD + git remote -v || true + + register: output + + - name: Local run context + debug: + var: output + + +- name: Configure Web + hosts: role_web + gather_facts: no + tasks: + - name: test1 + import_role: + name: activia.infra_common.configure_web + +- name: Configure DB + hosts: role_db + gather_facts: no + tasks: + - name: test2 + import_role: + name: activia.infra_common.configure_db + + diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..252c0f5 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +ansible==9.6.0 \ No newline at end of file diff --git a/requirements.yml b/requirements.yml new file mode 100644 index 0000000..2a71bea --- /dev/null +++ b/requirements.yml @@ -0,0 +1,5 @@ +collections: + - name: https://git.jeznet.org/activia-tests/ansible-collection-infra-common.git + type: git + version: main + \ No newline at end of file