From 0686328e9fcd20d41ab15148ec6edfe2a4c92519 Mon Sep 17 00:00:00 2001 From: Daniel Goldman Date: Sat, 25 Jun 2022 10:50:32 -0400 Subject: [PATCH 01/17] add other inventory useful for coupling the same playbook to different inventories --- helloansible/inventories/special_inventory.yml | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 helloansible/inventories/special_inventory.yml diff --git a/helloansible/inventories/special_inventory.yml b/helloansible/inventories/special_inventory.yml new file mode 100644 index 0000000..f69ac74 --- /dev/null +++ b/helloansible/inventories/special_inventory.yml @@ -0,0 +1,4 @@ +all: + hosts: + localhost: + overridden_var: "overridden_value" From 28120650f903f0fc7da4af11049f25a077bb222f Mon Sep 17 00:00:00 2001 From: Daniel Goldman Date: Sat, 25 Jun 2022 11:02:22 -0400 Subject: [PATCH 02/17] rename example role to clarify that it is being used as a local role ansible can use local roles and collections without them being built and installed, so long as they exist withing the directory convention --- helloansible/playbook.yml | 2 +- helloansible/roles/{example => local_role}/tasks/main.yml | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) rename helloansible/roles/{example => local_role}/tasks/main.yml (99%) diff --git a/helloansible/playbook.yml b/helloansible/playbook.yml index 0b2e6ae..47b407e 100644 --- a/helloansible/playbook.yml +++ b/helloansible/playbook.yml @@ -1,5 +1,5 @@ --- - hosts: localhost roles: - - role: example + - role: local_role - role: collectionexample diff --git a/helloansible/roles/example/tasks/main.yml b/helloansible/roles/local_role/tasks/main.yml similarity index 99% rename from helloansible/roles/example/tasks/main.yml rename to helloansible/roles/local_role/tasks/main.yml index 7defa8c..8fc65be 100644 --- a/helloansible/roles/example/tasks/main.yml +++ b/helloansible/roles/local_role/tasks/main.yml @@ -6,4 +6,3 @@ - name: Print out the results of the shell command ansible.builtin.debug: var: shell_result - From 10f26d62261338902201233fd1d061c8308adf0b Mon Sep 17 00:00:00 2001 From: Daniel Goldman Date: Sat, 25 Jun 2022 12:09:21 -0400 Subject: [PATCH 03/17] skel ansible collection --- .../my_namespace/my_collection/README.md | 3 + .../my_namespace/my_collection/galaxy.yml | 62 +++++++++++++++++++ .../my_collection/plugins/README.md | 31 ++++++++++ 3 files changed, 96 insertions(+) create mode 100644 helloansible/my_namespace/my_collection/README.md create mode 100644 helloansible/my_namespace/my_collection/galaxy.yml create mode 100644 helloansible/my_namespace/my_collection/plugins/README.md diff --git a/helloansible/my_namespace/my_collection/README.md b/helloansible/my_namespace/my_collection/README.md new file mode 100644 index 0000000..3eb3460 --- /dev/null +++ b/helloansible/my_namespace/my_collection/README.md @@ -0,0 +1,3 @@ +# Ansible Collection - my_namespace.my_collection + +Documentation for the collection. diff --git a/helloansible/my_namespace/my_collection/galaxy.yml b/helloansible/my_namespace/my_collection/galaxy.yml new file mode 100644 index 0000000..2cd3905 --- /dev/null +++ b/helloansible/my_namespace/my_collection/galaxy.yml @@ -0,0 +1,62 @@ +### REQUIRED +# The namespace of the collection. This can be a company/brand/organization or product namespace under which all +# content lives. May only contain alphanumeric lowercase characters and underscores. Namespaces cannot start with +# underscores or numbers and cannot contain consecutive underscores +namespace: my_namespace + +# The name of the collection. Has the same character restrictions as 'namespace' +name: my_collection + +# The version of the collection. Must be compatible with semantic versioning +version: 1.0.0 + +# The path to the Markdown (.md) readme file. This path is relative to the root of the collection +readme: README.md + +# A list of the collection's content authors. Can be just the name or in the format 'Full Name (url) +# @nicks:irc/im.site#channel' +authors: +- your name + + +### OPTIONAL but strongly recommended +# A short summary description of the collection +description: your collection description + +# Either a single license or a list of licenses for content inside of a collection. Ansible Galaxy currently only +# accepts L(SPDX,https://spdx.org/licenses/) licenses. This key is mutually exclusive with 'license_file' +license: +- GPL-2.0-or-later + +# The path to the license file for the collection. This path is relative to the root of the collection. This key is +# mutually exclusive with 'license' +license_file: '' + +# A list of tags you want to associate with the collection for indexing/searching. A tag name has the same character +# requirements as 'namespace' and 'name' +tags: [] + +# Collections that this collection requires to be installed for it to be usable. The key of the dict is the +# collection label 'namespace.name'. The value is a version range +# L(specifiers,https://python-semanticversion.readthedocs.io/en/latest/#requirement-specification). Multiple version +# range specifiers can be set and are separated by ',' +dependencies: {} + +# The URL of the originating SCM repository +repository: http://example.com/repository + +# The URL to any online docs +documentation: http://docs.example.com + +# The URL to the homepage of the collection/project +homepage: http://example.com + +# The URL to the collection issue tracker +issues: http://example.com/issue/tracker + +# A list of file glob-like patterns used to filter any files or directories that should not be included in the build +# artifact. A pattern is matched from the relative path of the file or directory of the collection directory. This +# uses 'fnmatch' to match the files or directories. Some directories and files like 'galaxy.yml', '*.pyc', '*.retry', +# and '.git' are always filtered +build_ignore: [] + diff --git a/helloansible/my_namespace/my_collection/plugins/README.md b/helloansible/my_namespace/my_collection/plugins/README.md new file mode 100644 index 0000000..775d977 --- /dev/null +++ b/helloansible/my_namespace/my_collection/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.12/plugins/plugins.html). From e5b1ad63a514c9c2d8012b71355e74bce550c7c3 Mon Sep 17 00:00:00 2001 From: Daniel Goldman Date: Sat, 25 Jun 2022 12:09:35 -0400 Subject: [PATCH 04/17] skel ansible role in collection --- .../roles/collection_role/.travis.yml | 29 +++++++++++ .../roles/collection_role/README.md | 38 ++++++++++++++ .../roles/collection_role/defaults/main.yml | 2 + .../roles/collection_role/handlers/main.yml | 2 + .../roles/collection_role/meta/main.yml | 52 +++++++++++++++++++ .../roles/collection_role/tasks/main.yml | 2 + .../roles/collection_role/tests/inventory | 2 + .../roles/collection_role/tests/test.yml | 5 ++ .../roles/collection_role/vars/main.yml | 2 + 9 files changed, 134 insertions(+) create mode 100644 helloansible/my_namespace/my_collection/roles/collection_role/.travis.yml create mode 100644 helloansible/my_namespace/my_collection/roles/collection_role/README.md create mode 100644 helloansible/my_namespace/my_collection/roles/collection_role/defaults/main.yml create mode 100644 helloansible/my_namespace/my_collection/roles/collection_role/handlers/main.yml create mode 100644 helloansible/my_namespace/my_collection/roles/collection_role/meta/main.yml create mode 100644 helloansible/my_namespace/my_collection/roles/collection_role/tasks/main.yml create mode 100644 helloansible/my_namespace/my_collection/roles/collection_role/tests/inventory create mode 100644 helloansible/my_namespace/my_collection/roles/collection_role/tests/test.yml create mode 100644 helloansible/my_namespace/my_collection/roles/collection_role/vars/main.yml diff --git a/helloansible/my_namespace/my_collection/roles/collection_role/.travis.yml b/helloansible/my_namespace/my_collection/roles/collection_role/.travis.yml new file mode 100644 index 0000000..36bbf62 --- /dev/null +++ b/helloansible/my_namespace/my_collection/roles/collection_role/.travis.yml @@ -0,0 +1,29 @@ +--- +language: python +python: "2.7" + +# Use the new container infrastructure +sudo: false + +# Install ansible +addons: + apt: + packages: + - python-pip + +install: + # Install ansible + - pip install ansible + + # Check ansible version + - ansible --version + + # Create ansible.cfg with correct roles_path + - printf '[defaults]\nroles_path=../' >ansible.cfg + +script: + # Basic role syntax check + - ansible-playbook tests/test.yml -i tests/inventory --syntax-check + +notifications: + webhooks: https://galaxy.ansible.com/api/v1/notifications/ \ No newline at end of file diff --git a/helloansible/my_namespace/my_collection/roles/collection_role/README.md b/helloansible/my_namespace/my_collection/roles/collection_role/README.md new file mode 100644 index 0000000..225dd44 --- /dev/null +++ b/helloansible/my_namespace/my_collection/roles/collection_role/README.md @@ -0,0 +1,38 @@ +Role Name +========= + +A brief description of the role goes here. + +Requirements +------------ + +Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required. + +Role Variables +-------------- + +A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well. + +Dependencies +------------ + +A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles. + +Example Playbook +---------------- + +Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: + + - hosts: servers + roles: + - { role: username.rolename, x: 42 } + +License +------- + +BSD + +Author Information +------------------ + +An optional section for the role authors to include contact information, or a website (HTML is not allowed). diff --git a/helloansible/my_namespace/my_collection/roles/collection_role/defaults/main.yml b/helloansible/my_namespace/my_collection/roles/collection_role/defaults/main.yml new file mode 100644 index 0000000..d782e77 --- /dev/null +++ b/helloansible/my_namespace/my_collection/roles/collection_role/defaults/main.yml @@ -0,0 +1,2 @@ +--- +# defaults file for collection_role diff --git a/helloansible/my_namespace/my_collection/roles/collection_role/handlers/main.yml b/helloansible/my_namespace/my_collection/roles/collection_role/handlers/main.yml new file mode 100644 index 0000000..a968830 --- /dev/null +++ b/helloansible/my_namespace/my_collection/roles/collection_role/handlers/main.yml @@ -0,0 +1,2 @@ +--- +# handlers file for collection_role diff --git a/helloansible/my_namespace/my_collection/roles/collection_role/meta/main.yml b/helloansible/my_namespace/my_collection/roles/collection_role/meta/main.yml new file mode 100644 index 0000000..c572acc --- /dev/null +++ b/helloansible/my_namespace/my_collection/roles/collection_role/meta/main.yml @@ -0,0 +1,52 @@ +galaxy_info: + author: your name + 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 + license: license (GPL-2.0-or-later, MIT, etc) + + 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. + +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/helloansible/my_namespace/my_collection/roles/collection_role/tasks/main.yml b/helloansible/my_namespace/my_collection/roles/collection_role/tasks/main.yml new file mode 100644 index 0000000..6d6488e --- /dev/null +++ b/helloansible/my_namespace/my_collection/roles/collection_role/tasks/main.yml @@ -0,0 +1,2 @@ +--- +# tasks file for collection_role diff --git a/helloansible/my_namespace/my_collection/roles/collection_role/tests/inventory b/helloansible/my_namespace/my_collection/roles/collection_role/tests/inventory new file mode 100644 index 0000000..878877b --- /dev/null +++ b/helloansible/my_namespace/my_collection/roles/collection_role/tests/inventory @@ -0,0 +1,2 @@ +localhost + diff --git a/helloansible/my_namespace/my_collection/roles/collection_role/tests/test.yml b/helloansible/my_namespace/my_collection/roles/collection_role/tests/test.yml new file mode 100644 index 0000000..81a63fa --- /dev/null +++ b/helloansible/my_namespace/my_collection/roles/collection_role/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: localhost + remote_user: root + roles: + - collection_role diff --git a/helloansible/my_namespace/my_collection/roles/collection_role/vars/main.yml b/helloansible/my_namespace/my_collection/roles/collection_role/vars/main.yml new file mode 100644 index 0000000..8397e4e --- /dev/null +++ b/helloansible/my_namespace/my_collection/roles/collection_role/vars/main.yml @@ -0,0 +1,2 @@ +--- +# vars file for collection_role From c82b1897761bab24431c17b3376058fc556e02b0 Mon Sep 17 00:00:00 2001 From: Daniel Goldman Date: Sat, 25 Jun 2022 15:41:59 -0400 Subject: [PATCH 05/17] remove skel travis file It has some YAML problems, but isn't taken in by pants as an ansible file, so there were conflicting lint error counts --- .../roles/collection_role/.travis.yml | 29 ------------------- 1 file changed, 29 deletions(-) delete mode 100644 helloansible/my_namespace/my_collection/roles/collection_role/.travis.yml diff --git a/helloansible/my_namespace/my_collection/roles/collection_role/.travis.yml b/helloansible/my_namespace/my_collection/roles/collection_role/.travis.yml deleted file mode 100644 index 36bbf62..0000000 --- a/helloansible/my_namespace/my_collection/roles/collection_role/.travis.yml +++ /dev/null @@ -1,29 +0,0 @@ ---- -language: python -python: "2.7" - -# Use the new container infrastructure -sudo: false - -# Install ansible -addons: - apt: - packages: - - python-pip - -install: - # Install ansible - - pip install ansible - - # Check ansible version - - ansible --version - - # Create ansible.cfg with correct roles_path - - printf '[defaults]\nroles_path=../' >ansible.cfg - -script: - # Basic role syntax check - - ansible-playbook tests/test.yml -i tests/inventory --syntax-check - -notifications: - webhooks: https://galaxy.ansible.com/api/v1/notifications/ \ No newline at end of file From 8650b74bf5594d5183c91b062021e93ed459b56a Mon Sep 17 00:00:00 2001 From: Daniel Goldman Date: Sat, 25 Jun 2022 15:51:11 -0400 Subject: [PATCH 06/17] move collection role into collection --- .../my_collection/roles/collection_role/tasks/main.yml | 8 +++++++- helloansible/playbook.yml | 2 +- helloansible/roles/collectionexample/tasks/main.yml | 8 -------- 3 files changed, 8 insertions(+), 10 deletions(-) delete mode 100644 helloansible/roles/collectionexample/tasks/main.yml diff --git a/helloansible/my_namespace/my_collection/roles/collection_role/tasks/main.yml b/helloansible/my_namespace/my_collection/roles/collection_role/tasks/main.yml index 6d6488e..4a1f38e 100644 --- a/helloansible/my_namespace/my_collection/roles/collection_role/tasks/main.yml +++ b/helloansible/my_namespace/my_collection/roles/collection_role/tasks/main.yml @@ -1,2 +1,8 @@ --- -# tasks file for collection_role +- name: Get info on docker host + community.docker.docker_host_info: + register: docker_result + +- name: Print out the results of the docker command + ansible.builtin.debug: + var: docker_result diff --git a/helloansible/playbook.yml b/helloansible/playbook.yml index 47b407e..d30d1b1 100644 --- a/helloansible/playbook.yml +++ b/helloansible/playbook.yml @@ -2,4 +2,4 @@ - hosts: localhost roles: - role: local_role - - role: collectionexample + - role: my_namespace.my_collection.collection_role diff --git a/helloansible/roles/collectionexample/tasks/main.yml b/helloansible/roles/collectionexample/tasks/main.yml deleted file mode 100644 index 4a1f38e..0000000 --- a/helloansible/roles/collectionexample/tasks/main.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- -- name: Get info on docker host - community.docker.docker_host_info: - register: docker_result - -- name: Print out the results of the docker command - ansible.builtin.debug: - var: docker_result From d609a513c8ad9ee9e6a1e9fc1a0f55e037c45839 Mon Sep 17 00:00:00 2001 From: Daniel Goldman Date: Sat, 25 Jun 2022 16:32:19 -0400 Subject: [PATCH 07/17] add local collection Local collections are poorly documented. Like local roles, they don't need to be installed to be referenced in playbooks. --- .../my_namespace/local_collection/README.md | 3 + .../my_namespace/local_collection/galaxy.yml | 62 +++++++++++++++++++ .../local_collection/plugins/README.md | 31 ++++++++++ .../roles/no_install/README.md | 38 ++++++++++++ .../roles/no_install/defaults/main.yml | 2 + .../roles/no_install/handlers/main.yml | 2 + .../roles/no_install/meta/main.yml | 52 ++++++++++++++++ .../roles/no_install/tasks/main.yml | 2 + .../roles/no_install/tests/inventory | 2 + .../roles/no_install/tests/test.yml | 5 ++ .../roles/no_install/vars/main.yml | 2 + helloansible/playbook.yml | 1 + 12 files changed, 202 insertions(+) create mode 100644 helloansible/collections/ansible_collections/my_namespace/local_collection/README.md create mode 100644 helloansible/collections/ansible_collections/my_namespace/local_collection/galaxy.yml create mode 100644 helloansible/collections/ansible_collections/my_namespace/local_collection/plugins/README.md create mode 100644 helloansible/collections/ansible_collections/my_namespace/local_collection/roles/no_install/README.md create mode 100644 helloansible/collections/ansible_collections/my_namespace/local_collection/roles/no_install/defaults/main.yml create mode 100644 helloansible/collections/ansible_collections/my_namespace/local_collection/roles/no_install/handlers/main.yml create mode 100644 helloansible/collections/ansible_collections/my_namespace/local_collection/roles/no_install/meta/main.yml create mode 100644 helloansible/collections/ansible_collections/my_namespace/local_collection/roles/no_install/tasks/main.yml create mode 100644 helloansible/collections/ansible_collections/my_namespace/local_collection/roles/no_install/tests/inventory create mode 100644 helloansible/collections/ansible_collections/my_namespace/local_collection/roles/no_install/tests/test.yml create mode 100644 helloansible/collections/ansible_collections/my_namespace/local_collection/roles/no_install/vars/main.yml diff --git a/helloansible/collections/ansible_collections/my_namespace/local_collection/README.md b/helloansible/collections/ansible_collections/my_namespace/local_collection/README.md new file mode 100644 index 0000000..f750405 --- /dev/null +++ b/helloansible/collections/ansible_collections/my_namespace/local_collection/README.md @@ -0,0 +1,3 @@ +# Ansible Collection - my_namespace.local_collection + +Documentation for the collection. diff --git a/helloansible/collections/ansible_collections/my_namespace/local_collection/galaxy.yml b/helloansible/collections/ansible_collections/my_namespace/local_collection/galaxy.yml new file mode 100644 index 0000000..3808260 --- /dev/null +++ b/helloansible/collections/ansible_collections/my_namespace/local_collection/galaxy.yml @@ -0,0 +1,62 @@ +### REQUIRED +# The namespace of the collection. This can be a company/brand/organization or product namespace under which all +# content lives. May only contain alphanumeric lowercase characters and underscores. Namespaces cannot start with +# underscores or numbers and cannot contain consecutive underscores +namespace: my_namespace + +# The name of the collection. Has the same character restrictions as 'namespace' +name: local_collection + +# The version of the collection. Must be compatible with semantic versioning +version: 1.0.0 + +# The path to the Markdown (.md) readme file. This path is relative to the root of the collection +readme: README.md + +# A list of the collection's content authors. Can be just the name or in the format 'Full Name (url) +# @nicks:irc/im.site#channel' +authors: +- your name + + +### OPTIONAL but strongly recommended +# A short summary description of the collection +description: your collection description + +# Either a single license or a list of licenses for content inside of a collection. Ansible Galaxy currently only +# accepts L(SPDX,https://spdx.org/licenses/) licenses. This key is mutually exclusive with 'license_file' +license: +- GPL-2.0-or-later + +# The path to the license file for the collection. This path is relative to the root of the collection. This key is +# mutually exclusive with 'license' +license_file: '' + +# A list of tags you want to associate with the collection for indexing/searching. A tag name has the same character +# requirements as 'namespace' and 'name' +tags: [] + +# Collections that this collection requires to be installed for it to be usable. The key of the dict is the +# collection label 'namespace.name'. The value is a version range +# L(specifiers,https://python-semanticversion.readthedocs.io/en/latest/#requirement-specification). Multiple version +# range specifiers can be set and are separated by ',' +dependencies: {} + +# The URL of the originating SCM repository +repository: http://example.com/repository + +# The URL to any online docs +documentation: http://docs.example.com + +# The URL to the homepage of the collection/project +homepage: http://example.com + +# The URL to the collection issue tracker +issues: http://example.com/issue/tracker + +# A list of file glob-like patterns used to filter any files or directories that should not be included in the build +# artifact. A pattern is matched from the relative path of the file or directory of the collection directory. This +# uses 'fnmatch' to match the files or directories. Some directories and files like 'galaxy.yml', '*.pyc', '*.retry', +# and '.git' are always filtered +build_ignore: [] + diff --git a/helloansible/collections/ansible_collections/my_namespace/local_collection/plugins/README.md b/helloansible/collections/ansible_collections/my_namespace/local_collection/plugins/README.md new file mode 100644 index 0000000..775d977 --- /dev/null +++ b/helloansible/collections/ansible_collections/my_namespace/local_collection/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.12/plugins/plugins.html). diff --git a/helloansible/collections/ansible_collections/my_namespace/local_collection/roles/no_install/README.md b/helloansible/collections/ansible_collections/my_namespace/local_collection/roles/no_install/README.md new file mode 100644 index 0000000..225dd44 --- /dev/null +++ b/helloansible/collections/ansible_collections/my_namespace/local_collection/roles/no_install/README.md @@ -0,0 +1,38 @@ +Role Name +========= + +A brief description of the role goes here. + +Requirements +------------ + +Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required. + +Role Variables +-------------- + +A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well. + +Dependencies +------------ + +A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles. + +Example Playbook +---------------- + +Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: + + - hosts: servers + roles: + - { role: username.rolename, x: 42 } + +License +------- + +BSD + +Author Information +------------------ + +An optional section for the role authors to include contact information, or a website (HTML is not allowed). diff --git a/helloansible/collections/ansible_collections/my_namespace/local_collection/roles/no_install/defaults/main.yml b/helloansible/collections/ansible_collections/my_namespace/local_collection/roles/no_install/defaults/main.yml new file mode 100644 index 0000000..359a3e6 --- /dev/null +++ b/helloansible/collections/ansible_collections/my_namespace/local_collection/roles/no_install/defaults/main.yml @@ -0,0 +1,2 @@ +--- +# defaults file for no_install diff --git a/helloansible/collections/ansible_collections/my_namespace/local_collection/roles/no_install/handlers/main.yml b/helloansible/collections/ansible_collections/my_namespace/local_collection/roles/no_install/handlers/main.yml new file mode 100644 index 0000000..cef442d --- /dev/null +++ b/helloansible/collections/ansible_collections/my_namespace/local_collection/roles/no_install/handlers/main.yml @@ -0,0 +1,2 @@ +--- +# handlers file for no_install diff --git a/helloansible/collections/ansible_collections/my_namespace/local_collection/roles/no_install/meta/main.yml b/helloansible/collections/ansible_collections/my_namespace/local_collection/roles/no_install/meta/main.yml new file mode 100644 index 0000000..c572acc --- /dev/null +++ b/helloansible/collections/ansible_collections/my_namespace/local_collection/roles/no_install/meta/main.yml @@ -0,0 +1,52 @@ +galaxy_info: + author: your name + 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 + license: license (GPL-2.0-or-later, MIT, etc) + + 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. + +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/helloansible/collections/ansible_collections/my_namespace/local_collection/roles/no_install/tasks/main.yml b/helloansible/collections/ansible_collections/my_namespace/local_collection/roles/no_install/tasks/main.yml new file mode 100644 index 0000000..553b7be --- /dev/null +++ b/helloansible/collections/ansible_collections/my_namespace/local_collection/roles/no_install/tasks/main.yml @@ -0,0 +1,2 @@ +--- +# tasks file for no_install diff --git a/helloansible/collections/ansible_collections/my_namespace/local_collection/roles/no_install/tests/inventory b/helloansible/collections/ansible_collections/my_namespace/local_collection/roles/no_install/tests/inventory new file mode 100644 index 0000000..878877b --- /dev/null +++ b/helloansible/collections/ansible_collections/my_namespace/local_collection/roles/no_install/tests/inventory @@ -0,0 +1,2 @@ +localhost + diff --git a/helloansible/collections/ansible_collections/my_namespace/local_collection/roles/no_install/tests/test.yml b/helloansible/collections/ansible_collections/my_namespace/local_collection/roles/no_install/tests/test.yml new file mode 100644 index 0000000..be167ad --- /dev/null +++ b/helloansible/collections/ansible_collections/my_namespace/local_collection/roles/no_install/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: localhost + remote_user: root + roles: + - no_install diff --git a/helloansible/collections/ansible_collections/my_namespace/local_collection/roles/no_install/vars/main.yml b/helloansible/collections/ansible_collections/my_namespace/local_collection/roles/no_install/vars/main.yml new file mode 100644 index 0000000..671ba0a --- /dev/null +++ b/helloansible/collections/ansible_collections/my_namespace/local_collection/roles/no_install/vars/main.yml @@ -0,0 +1,2 @@ +--- +# vars file for no_install diff --git a/helloansible/playbook.yml b/helloansible/playbook.yml index d30d1b1..60386a2 100644 --- a/helloansible/playbook.yml +++ b/helloansible/playbook.yml @@ -2,4 +2,5 @@ - hosts: localhost roles: - role: local_role + - role: my_namespace.local_collection.no_install - role: my_namespace.my_collection.collection_role From 886814f77836117719667e0075fa1e7401af2afe Mon Sep 17 00:00:00 2001 From: Daniel Goldman Date: Sat, 25 Jun 2022 16:44:36 -0400 Subject: [PATCH 08/17] patch over failing dependency resolution waiting on other features to be implemented --- .ansible-lint | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .ansible-lint diff --git a/.ansible-lint b/.ansible-lint new file mode 100644 index 0000000..703fa12 --- /dev/null +++ b/.ansible-lint @@ -0,0 +1,4 @@ +mock_modules: + - "community.docker.docker_host_info" # TODO: requires dependency fetching +mock_roles: + - "my_namespace.my_collection.collection_role" # TODO: requires building local collections From 6dbd28d633366f915aeeda7ab755d88ab2103cdb Mon Sep 17 00:00:00 2001 From: Daniel Goldman Date: Sat, 25 Jun 2022 16:52:09 -0400 Subject: [PATCH 09/17] finish skelling local_role --- helloansible/roles/local_role/README.md | 38 ++++++++++++++ .../roles/local_role/defaults/main.yml | 2 + .../roles/local_role/handlers/main.yml | 2 + helloansible/roles/local_role/meta/main.yml | 52 +++++++++++++++++++ helloansible/roles/local_role/tests/inventory | 2 + helloansible/roles/local_role/tests/test.yml | 5 ++ helloansible/roles/local_role/vars/main.yml | 2 + 7 files changed, 103 insertions(+) create mode 100644 helloansible/roles/local_role/README.md create mode 100644 helloansible/roles/local_role/defaults/main.yml create mode 100644 helloansible/roles/local_role/handlers/main.yml create mode 100644 helloansible/roles/local_role/meta/main.yml create mode 100644 helloansible/roles/local_role/tests/inventory create mode 100644 helloansible/roles/local_role/tests/test.yml create mode 100644 helloansible/roles/local_role/vars/main.yml diff --git a/helloansible/roles/local_role/README.md b/helloansible/roles/local_role/README.md new file mode 100644 index 0000000..225dd44 --- /dev/null +++ b/helloansible/roles/local_role/README.md @@ -0,0 +1,38 @@ +Role Name +========= + +A brief description of the role goes here. + +Requirements +------------ + +Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required. + +Role Variables +-------------- + +A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well. + +Dependencies +------------ + +A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles. + +Example Playbook +---------------- + +Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: + + - hosts: servers + roles: + - { role: username.rolename, x: 42 } + +License +------- + +BSD + +Author Information +------------------ + +An optional section for the role authors to include contact information, or a website (HTML is not allowed). diff --git a/helloansible/roles/local_role/defaults/main.yml b/helloansible/roles/local_role/defaults/main.yml new file mode 100644 index 0000000..3f5f183 --- /dev/null +++ b/helloansible/roles/local_role/defaults/main.yml @@ -0,0 +1,2 @@ +--- +# defaults file for local_role diff --git a/helloansible/roles/local_role/handlers/main.yml b/helloansible/roles/local_role/handlers/main.yml new file mode 100644 index 0000000..61a4506 --- /dev/null +++ b/helloansible/roles/local_role/handlers/main.yml @@ -0,0 +1,2 @@ +--- +# handlers file for local_role diff --git a/helloansible/roles/local_role/meta/main.yml b/helloansible/roles/local_role/meta/main.yml new file mode 100644 index 0000000..c572acc --- /dev/null +++ b/helloansible/roles/local_role/meta/main.yml @@ -0,0 +1,52 @@ +galaxy_info: + author: your name + 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 + license: license (GPL-2.0-or-later, MIT, etc) + + 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. + +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/helloansible/roles/local_role/tests/inventory b/helloansible/roles/local_role/tests/inventory new file mode 100644 index 0000000..878877b --- /dev/null +++ b/helloansible/roles/local_role/tests/inventory @@ -0,0 +1,2 @@ +localhost + diff --git a/helloansible/roles/local_role/tests/test.yml b/helloansible/roles/local_role/tests/test.yml new file mode 100644 index 0000000..427caa1 --- /dev/null +++ b/helloansible/roles/local_role/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: localhost + remote_user: root + roles: + - local_role diff --git a/helloansible/roles/local_role/vars/main.yml b/helloansible/roles/local_role/vars/main.yml new file mode 100644 index 0000000..d53afa8 --- /dev/null +++ b/helloansible/roles/local_role/vars/main.yml @@ -0,0 +1,2 @@ +--- +# vars file for local_role From c911e088ecbeeef62038a62f666d897b6008b52a Mon Sep 17 00:00:00 2001 From: Daniel Goldman Date: Sat, 25 Jun 2022 17:03:44 -0400 Subject: [PATCH 10/17] add dependencies in collection galaxy.yml --- .../my_namespace/local_collection/galaxy.yml | 3 ++- helloansible/my_namespace/my_collection/galaxy.yml | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/helloansible/collections/ansible_collections/my_namespace/local_collection/galaxy.yml b/helloansible/collections/ansible_collections/my_namespace/local_collection/galaxy.yml index 3808260..1105f78 100644 --- a/helloansible/collections/ansible_collections/my_namespace/local_collection/galaxy.yml +++ b/helloansible/collections/ansible_collections/my_namespace/local_collection/galaxy.yml @@ -40,7 +40,8 @@ tags: [] # collection label 'namespace.name'. The value is a version range # L(specifiers,https://python-semanticversion.readthedocs.io/en/latest/#requirement-specification). Multiple version # range specifiers can be set and are separated by ',' -dependencies: {} +dependencies: + ansible.posix: "==1.4.0" # The URL of the originating SCM repository repository: http://example.com/repository diff --git a/helloansible/my_namespace/my_collection/galaxy.yml b/helloansible/my_namespace/my_collection/galaxy.yml index 2cd3905..5292dd2 100644 --- a/helloansible/my_namespace/my_collection/galaxy.yml +++ b/helloansible/my_namespace/my_collection/galaxy.yml @@ -40,7 +40,8 @@ tags: [] # collection label 'namespace.name'. The value is a version range # L(specifiers,https://python-semanticversion.readthedocs.io/en/latest/#requirement-specification). Multiple version # range specifiers can be set and are separated by ',' -dependencies: {} +dependencies: + community.crypto: "==2.3.4" # The URL of the originating SCM repository repository: http://example.com/repository From 92108aaee6e49510cb361d756dc89d84a7ed442d Mon Sep 17 00:00:00 2001 From: Daniel Goldman Date: Sat, 25 Jun 2022 17:06:02 -0400 Subject: [PATCH 11/17] add other playbook and playbook import statement --- helloansible/other_playbook.yml | 6 ++++++ helloansible/playbook.yml | 2 ++ 2 files changed, 8 insertions(+) create mode 100644 helloansible/other_playbook.yml diff --git a/helloansible/other_playbook.yml b/helloansible/other_playbook.yml new file mode 100644 index 0000000..a8b1f46 --- /dev/null +++ b/helloansible/other_playbook.yml @@ -0,0 +1,6 @@ +--- +- hosts: localhost + tasks: + - name: in other playbook + ansible.builtin.debug: + msg: "in other playbook" diff --git a/helloansible/playbook.yml b/helloansible/playbook.yml index 60386a2..cb417fa 100644 --- a/helloansible/playbook.yml +++ b/helloansible/playbook.yml @@ -4,3 +4,5 @@ - role: local_role - role: my_namespace.local_collection.no_install - role: my_namespace.my_collection.collection_role + +- import_playbook: other_playbook.yml From b7919b7f6e4d4de0787c44d6498135a57d2b349f Mon Sep 17 00:00:00 2001 From: Daniel Goldman Date: Sat, 25 Jun 2022 17:28:19 -0400 Subject: [PATCH 12/17] add role dependencies for now, they just depend on local roles and don't require galaxy installs. Because I don't know of a good no-op role --- .../roles/no_install/meta/main.yml | 7 ++++--- .../roles/collection_role/meta/main.yml | 7 ++++--- helloansible/readme.md | 19 +++++++++++++++++++ .../roles/local_role/defaults/main.yml | 2 +- helloansible/roles/local_role/tasks/main.yml | 4 ++++ 5 files changed, 32 insertions(+), 7 deletions(-) create mode 100644 helloansible/readme.md diff --git a/helloansible/collections/ansible_collections/my_namespace/local_collection/roles/no_install/meta/main.yml b/helloansible/collections/ansible_collections/my_namespace/local_collection/roles/no_install/meta/main.yml index c572acc..5dbc867 100644 --- a/helloansible/collections/ansible_collections/my_namespace/local_collection/roles/no_install/meta/main.yml +++ b/helloansible/collections/ansible_collections/my_namespace/local_collection/roles/no_install/meta/main.yml @@ -47,6 +47,7 @@ galaxy_info: # 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. +dependencies: + - role: local_role + vars: + parent: "my_namespace.local_collection.no_install" diff --git a/helloansible/my_namespace/my_collection/roles/collection_role/meta/main.yml b/helloansible/my_namespace/my_collection/roles/collection_role/meta/main.yml index c572acc..ad928a3 100644 --- a/helloansible/my_namespace/my_collection/roles/collection_role/meta/main.yml +++ b/helloansible/my_namespace/my_collection/roles/collection_role/meta/main.yml @@ -47,6 +47,7 @@ galaxy_info: # 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. +dependencies: + - role: local_role + vars: + parent: "my_namespace.my_collection.collection_role" \ No newline at end of file diff --git a/helloansible/readme.md b/helloansible/readme.md new file mode 100644 index 0000000..7e4fbdf --- /dev/null +++ b/helloansible/readme.md @@ -0,0 +1,19 @@ +# helloansible + +This is a sample Ansible repo. It has many of the different pieces an Ansible repository can have: + +## Collections and Roles + +- "collections/ansible_collections" : local collections which don't require installation to be used +- "./my_namespace/my_collection/" : a collection which needs to be built before it can be used +- "./roles" : local roles which don't require installation to be used + +## Dependencies + +A top-level requirements.yml file. These files are used for playbook dependencies +Each of the collections also includes dependencies in their galaxy.yml files +The collection roles also have a dependency on the local role. Roles are also able to pull in galaxy roles, but we'd need to find a good no-op role for that. + +## Playbooks + +There are several inventories, in ini and yaml formats. \ No newline at end of file diff --git a/helloansible/roles/local_role/defaults/main.yml b/helloansible/roles/local_role/defaults/main.yml index 3f5f183..6102645 100644 --- a/helloansible/roles/local_role/defaults/main.yml +++ b/helloansible/roles/local_role/defaults/main.yml @@ -1,2 +1,2 @@ --- -# defaults file for local_role +parent: "none" diff --git a/helloansible/roles/local_role/tasks/main.yml b/helloansible/roles/local_role/tasks/main.yml index 8fc65be..d65b5aa 100644 --- a/helloansible/roles/local_role/tasks/main.yml +++ b/helloansible/roles/local_role/tasks/main.yml @@ -6,3 +6,7 @@ - name: Print out the results of the shell command ansible.builtin.debug: var: shell_result + +- name: Print parent + ansible.builtin.debug: + var: parent \ No newline at end of file From 381cdae200aa3cc654ee1eceafce3622f595a0f1 Mon Sep 17 00:00:00 2001 From: Daniel Goldman Date: Sat, 25 Jun 2022 17:34:31 -0400 Subject: [PATCH 13/17] retailor --- BUILD | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 BUILD diff --git a/BUILD b/BUILD new file mode 100644 index 0000000..b576654 --- /dev/null +++ b/BUILD @@ -0,0 +1,4 @@ +python_requirements( + name="root", + source="requirements.constraints.txt", +) From 810639b6fd1dcdf354e13c1f1b4492f3e3de11d5 Mon Sep 17 00:00:00 2001 From: Daniel Goldman Date: Sat, 25 Jun 2022 17:45:38 -0400 Subject: [PATCH 14/17] fix lint that only showed up outside of pants running it with pants would not find this error --- .../my_collection/roles/collection_role/meta/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helloansible/my_namespace/my_collection/roles/collection_role/meta/main.yml b/helloansible/my_namespace/my_collection/roles/collection_role/meta/main.yml index ad928a3..724b888 100644 --- a/helloansible/my_namespace/my_collection/roles/collection_role/meta/main.yml +++ b/helloansible/my_namespace/my_collection/roles/collection_role/meta/main.yml @@ -50,4 +50,4 @@ galaxy_info: dependencies: - role: local_role vars: - parent: "my_namespace.my_collection.collection_role" \ No newline at end of file + parent: "my_namespace.my_collection.collection_role" From dac38dd06a09d31103a6dc39cdf4633455e0f3af Mon Sep 17 00:00:00 2001 From: Daniel Goldman Date: Sat, 25 Jun 2022 18:10:02 -0400 Subject: [PATCH 15/17] fmt BUILD file --- helloswift/BUILD.pants | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/helloswift/BUILD.pants b/helloswift/BUILD.pants index 938e90d..3d5b426 100644 --- a/helloswift/BUILD.pants +++ b/helloswift/BUILD.pants @@ -1,14 +1,14 @@ swift_sources( name="libcore", - sources=["Core/*.swift"] + sources=["Core/*.swift"], ) swift_sources( name="libhelloworld", - sources=["Sources/*.swift"] + sources=["Sources/*.swift"], ) swift_binary( name="bin", - dependencies=[":lib"] -) \ No newline at end of file + dependencies=[":lib"], +) From c42f55d7bc355e6b794669dc2a7ff638a7b515fa Mon Sep 17 00:00:00 2001 From: SJ Date: Sat, 25 Jun 2022 22:09:41 -0400 Subject: [PATCH 16/17] See issue #70: Renaming Readme to get case correct --- helloansible/{readme.md => README1.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename helloansible/{readme.md => README1.md} (100%) diff --git a/helloansible/readme.md b/helloansible/README1.md similarity index 100% rename from helloansible/readme.md rename to helloansible/README1.md From de43358f3a91a8cce8f27a7e470a3cbd5fcf007c Mon Sep 17 00:00:00 2001 From: SJ Date: Sat, 25 Jun 2022 22:09:53 -0400 Subject: [PATCH 17/17] Ditto --- helloansible/{README1.md => README.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename helloansible/{README1.md => README.md} (100%) diff --git a/helloansible/README1.md b/helloansible/README.md similarity index 100% rename from helloansible/README1.md rename to helloansible/README.md