From 7ab1d4770c744f1bf2742b799e4cd9ce6d2ef84e Mon Sep 17 00:00:00 2001 From: shatakshiiii Date: Tue, 27 Feb 2024 13:06:08 +0530 Subject: [PATCH 1/9] Scaffold playbook and role in collection init --- .config/dictionary.txt | 3 ++ .../playbooks/first_playbook_ext.yml.j2 | 29 +++++++++++ .../playbooks/update_servers.yml.j2 | 29 +++++++++++ .../roles/my_first_role/README.md.j2 | 38 ++++++++++++++ .../roles/my_first_role/defaults/main.yml | 2 + .../roles/my_first_role/handlers/main.yml | 2 + .../roles/my_first_role/meta/main.yml.j2 | 52 +++++++++++++++++++ .../roles/my_first_role/tasks/main.yml | 2 + .../roles/my_first_role/tests/inventory | 1 + .../roles/my_first_role/tests/test.yml | 5 ++ .../roles/my_first_role/vars/main.yml | 2 + 11 files changed, 165 insertions(+) create mode 100644 src/ansible_creator/resources/new_collection/playbooks/first_playbook_ext.yml.j2 create mode 100644 src/ansible_creator/resources/new_collection/playbooks/update_servers.yml.j2 create mode 100644 src/ansible_creator/resources/new_collection/roles/my_first_role/README.md.j2 create mode 100644 src/ansible_creator/resources/new_collection/roles/my_first_role/defaults/main.yml create mode 100644 src/ansible_creator/resources/new_collection/roles/my_first_role/handlers/main.yml create mode 100644 src/ansible_creator/resources/new_collection/roles/my_first_role/meta/main.yml.j2 create mode 100644 src/ansible_creator/resources/new_collection/roles/my_first_role/tasks/main.yml create mode 100644 src/ansible_creator/resources/new_collection/roles/my_first_role/tests/inventory create mode 100644 src/ansible_creator/resources/new_collection/roles/my_first_role/tests/test.yml create mode 100644 src/ansible_creator/resources/new_collection/roles/my_first_role/vars/main.yml diff --git a/.config/dictionary.txt b/.config/dictionary.txt index db1e6030..2aac38ef 100644 --- a/.config/dictionary.txt +++ b/.config/dictionary.txt @@ -12,6 +12,7 @@ astimezone autorefs autosectionlabel basesystem +boto BUILDDIR caplog capsys @@ -110,6 +111,7 @@ representer Representer returndocs Rocannon's +rolename rtype rulebook rulebooks @@ -160,6 +162,7 @@ userbase viewcode volmount wantd +webservers workdir xdist xmss diff --git a/src/ansible_creator/resources/new_collection/playbooks/first_playbook_ext.yml.j2 b/src/ansible_creator/resources/new_collection/playbooks/first_playbook_ext.yml.j2 new file mode 100644 index 00000000..0aba277b --- /dev/null +++ b/src/ansible_creator/resources/new_collection/playbooks/first_playbook_ext.yml.j2 @@ -0,0 +1,29 @@ +{% raw %}--- +- name: Network Getting Started First Playbook Extended + connection: ansible.netcommon.network_cli + gather_facts: false + hosts: all + tasks: + + - name: Get config for VyOS devices + vyos.vyos.vyos_facts: + gather_subset: all + + - name: Display the config + debug: + msg: "The hostname is {{ ansible_net_hostname }} and the OS is {{ ansible_net_version }}" + + - name: Update the hostname + vyos.vyos.vyos_config: + backup: yes + lines: + - set system host-name vyos-changed + + - name: Get changed config for VyOS devices + vyos.vyos.vyos_facts: + gather_subset: all + + - name: Display the changed config + debug: + msg: "The new hostname is {{ ansible_net_hostname }} and the OS is {{ ansible_net_version }}" +{%- endraw %} diff --git a/src/ansible_creator/resources/new_collection/playbooks/update_servers.yml.j2 b/src/ansible_creator/resources/new_collection/playbooks/update_servers.yml.j2 new file mode 100644 index 00000000..13a7ac42 --- /dev/null +++ b/src/ansible_creator/resources/new_collection/playbooks/update_servers.yml.j2 @@ -0,0 +1,29 @@ +--- +- name: Update web servers + hosts: webservers + become: true + + tasks: + - name: Ensure apache is at the latest version + ansible.builtin.yum: + name: httpd + state: latest + - name: Write the apache config file + ansible.builtin.template: + src: /srv/httpd.j2 + dest: /etc/httpd.conf + mode: "0644" + +- name: Update db servers + hosts: databases + become: true + + tasks: + - name: Ensure postgresql is at the latest version + ansible.builtin.yum: + name: postgresql + state: latest + - name: Ensure that postgresql is started + ansible.builtin.service: + name: postgresql + state: started diff --git a/src/ansible_creator/resources/new_collection/roles/my_first_role/README.md.j2 b/src/ansible_creator/resources/new_collection/roles/my_first_role/README.md.j2 new file mode 100644 index 00000000..225dd44b --- /dev/null +++ b/src/ansible_creator/resources/new_collection/roles/my_first_role/README.md.j2 @@ -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/src/ansible_creator/resources/new_collection/roles/my_first_role/defaults/main.yml b/src/ansible_creator/resources/new_collection/roles/my_first_role/defaults/main.yml new file mode 100644 index 00000000..d7044342 --- /dev/null +++ b/src/ansible_creator/resources/new_collection/roles/my_first_role/defaults/main.yml @@ -0,0 +1,2 @@ +--- +# defaults file for my_first_role diff --git a/src/ansible_creator/resources/new_collection/roles/my_first_role/handlers/main.yml b/src/ansible_creator/resources/new_collection/roles/my_first_role/handlers/main.yml new file mode 100644 index 00000000..6d962c8d --- /dev/null +++ b/src/ansible_creator/resources/new_collection/roles/my_first_role/handlers/main.yml @@ -0,0 +1,2 @@ +--- +# handlers file for my_first_role diff --git a/src/ansible_creator/resources/new_collection/roles/my_first_role/meta/main.yml.j2 b/src/ansible_creator/resources/new_collection/roles/my_first_role/meta/main.yml.j2 new file mode 100644 index 00000000..c572acc9 --- /dev/null +++ b/src/ansible_creator/resources/new_collection/roles/my_first_role/meta/main.yml.j2 @@ -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/src/ansible_creator/resources/new_collection/roles/my_first_role/tasks/main.yml b/src/ansible_creator/resources/new_collection/roles/my_first_role/tasks/main.yml new file mode 100644 index 00000000..4252735e --- /dev/null +++ b/src/ansible_creator/resources/new_collection/roles/my_first_role/tasks/main.yml @@ -0,0 +1,2 @@ +--- +# tasks file for my_first_role diff --git a/src/ansible_creator/resources/new_collection/roles/my_first_role/tests/inventory b/src/ansible_creator/resources/new_collection/roles/my_first_role/tests/inventory new file mode 100644 index 00000000..2fbb50c4 --- /dev/null +++ b/src/ansible_creator/resources/new_collection/roles/my_first_role/tests/inventory @@ -0,0 +1 @@ +localhost diff --git a/src/ansible_creator/resources/new_collection/roles/my_first_role/tests/test.yml b/src/ansible_creator/resources/new_collection/roles/my_first_role/tests/test.yml new file mode 100644 index 00000000..69002992 --- /dev/null +++ b/src/ansible_creator/resources/new_collection/roles/my_first_role/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: localhost + remote_user: root + roles: + - my_first_role diff --git a/src/ansible_creator/resources/new_collection/roles/my_first_role/vars/main.yml b/src/ansible_creator/resources/new_collection/roles/my_first_role/vars/main.yml new file mode 100644 index 00000000..017705ee --- /dev/null +++ b/src/ansible_creator/resources/new_collection/roles/my_first_role/vars/main.yml @@ -0,0 +1,2 @@ +--- +# vars file for my_first_role From fa423d90cc85e611196bdb823b273804700f412b Mon Sep 17 00:00:00 2001 From: shatakshiiii Date: Fri, 1 Mar 2024 19:21:17 +0530 Subject: [PATCH 2/9] Add related tests --- .../testcol/playbooks/first_playbook_ext.yml | 28 ++++++++++ .../testcol/playbooks/update_servers.yml | 29 +++++++++++ .../testcol/roles/my_first_role/README.md | 38 ++++++++++++++ .../roles/my_first_role/defaults/main.yml | 2 + .../roles/my_first_role/handlers/main.yml | 2 + .../testcol/roles/my_first_role/meta/main.yml | 52 +++++++++++++++++++ .../roles/my_first_role/tasks/main.yml | 2 + .../roles/my_first_role/tests/inventory | 1 + .../roles/my_first_role/tests/test.yml | 5 ++ .../testcol/roles/my_first_role/vars/main.yml | 2 + 10 files changed, 161 insertions(+) create mode 100644 tests/fixtures/collection/testorg/testcol/playbooks/first_playbook_ext.yml create mode 100644 tests/fixtures/collection/testorg/testcol/playbooks/update_servers.yml create mode 100644 tests/fixtures/collection/testorg/testcol/roles/my_first_role/README.md create mode 100644 tests/fixtures/collection/testorg/testcol/roles/my_first_role/defaults/main.yml create mode 100644 tests/fixtures/collection/testorg/testcol/roles/my_first_role/handlers/main.yml create mode 100644 tests/fixtures/collection/testorg/testcol/roles/my_first_role/meta/main.yml create mode 100644 tests/fixtures/collection/testorg/testcol/roles/my_first_role/tasks/main.yml create mode 100644 tests/fixtures/collection/testorg/testcol/roles/my_first_role/tests/inventory create mode 100644 tests/fixtures/collection/testorg/testcol/roles/my_first_role/tests/test.yml create mode 100644 tests/fixtures/collection/testorg/testcol/roles/my_first_role/vars/main.yml diff --git a/tests/fixtures/collection/testorg/testcol/playbooks/first_playbook_ext.yml b/tests/fixtures/collection/testorg/testcol/playbooks/first_playbook_ext.yml new file mode 100644 index 00000000..0ab87906 --- /dev/null +++ b/tests/fixtures/collection/testorg/testcol/playbooks/first_playbook_ext.yml @@ -0,0 +1,28 @@ +--- +- name: Network Getting Started First Playbook Extended + connection: ansible.netcommon.network_cli + gather_facts: false + hosts: all + tasks: + + - name: Get config for VyOS devices + vyos.vyos.vyos_facts: + gather_subset: all + + - name: Display the config + debug: + msg: "The hostname is {{ ansible_net_hostname }} and the OS is {{ ansible_net_version }}" + + - name: Update the hostname + vyos.vyos.vyos_config: + backup: yes + lines: + - set system host-name vyos-changed + + - name: Get changed config for VyOS devices + vyos.vyos.vyos_facts: + gather_subset: all + + - name: Display the changed config + debug: + msg: "The new hostname is {{ ansible_net_hostname }} and the OS is {{ ansible_net_version }}" diff --git a/tests/fixtures/collection/testorg/testcol/playbooks/update_servers.yml b/tests/fixtures/collection/testorg/testcol/playbooks/update_servers.yml new file mode 100644 index 00000000..13a7ac42 --- /dev/null +++ b/tests/fixtures/collection/testorg/testcol/playbooks/update_servers.yml @@ -0,0 +1,29 @@ +--- +- name: Update web servers + hosts: webservers + become: true + + tasks: + - name: Ensure apache is at the latest version + ansible.builtin.yum: + name: httpd + state: latest + - name: Write the apache config file + ansible.builtin.template: + src: /srv/httpd.j2 + dest: /etc/httpd.conf + mode: "0644" + +- name: Update db servers + hosts: databases + become: true + + tasks: + - name: Ensure postgresql is at the latest version + ansible.builtin.yum: + name: postgresql + state: latest + - name: Ensure that postgresql is started + ansible.builtin.service: + name: postgresql + state: started diff --git a/tests/fixtures/collection/testorg/testcol/roles/my_first_role/README.md b/tests/fixtures/collection/testorg/testcol/roles/my_first_role/README.md new file mode 100644 index 00000000..225dd44b --- /dev/null +++ b/tests/fixtures/collection/testorg/testcol/roles/my_first_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/tests/fixtures/collection/testorg/testcol/roles/my_first_role/defaults/main.yml b/tests/fixtures/collection/testorg/testcol/roles/my_first_role/defaults/main.yml new file mode 100644 index 00000000..d7044342 --- /dev/null +++ b/tests/fixtures/collection/testorg/testcol/roles/my_first_role/defaults/main.yml @@ -0,0 +1,2 @@ +--- +# defaults file for my_first_role diff --git a/tests/fixtures/collection/testorg/testcol/roles/my_first_role/handlers/main.yml b/tests/fixtures/collection/testorg/testcol/roles/my_first_role/handlers/main.yml new file mode 100644 index 00000000..6d962c8d --- /dev/null +++ b/tests/fixtures/collection/testorg/testcol/roles/my_first_role/handlers/main.yml @@ -0,0 +1,2 @@ +--- +# handlers file for my_first_role diff --git a/tests/fixtures/collection/testorg/testcol/roles/my_first_role/meta/main.yml b/tests/fixtures/collection/testorg/testcol/roles/my_first_role/meta/main.yml new file mode 100644 index 00000000..c572acc9 --- /dev/null +++ b/tests/fixtures/collection/testorg/testcol/roles/my_first_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/tests/fixtures/collection/testorg/testcol/roles/my_first_role/tasks/main.yml b/tests/fixtures/collection/testorg/testcol/roles/my_first_role/tasks/main.yml new file mode 100644 index 00000000..4252735e --- /dev/null +++ b/tests/fixtures/collection/testorg/testcol/roles/my_first_role/tasks/main.yml @@ -0,0 +1,2 @@ +--- +# tasks file for my_first_role diff --git a/tests/fixtures/collection/testorg/testcol/roles/my_first_role/tests/inventory b/tests/fixtures/collection/testorg/testcol/roles/my_first_role/tests/inventory new file mode 100644 index 00000000..2fbb50c4 --- /dev/null +++ b/tests/fixtures/collection/testorg/testcol/roles/my_first_role/tests/inventory @@ -0,0 +1 @@ +localhost diff --git a/tests/fixtures/collection/testorg/testcol/roles/my_first_role/tests/test.yml b/tests/fixtures/collection/testorg/testcol/roles/my_first_role/tests/test.yml new file mode 100644 index 00000000..69002992 --- /dev/null +++ b/tests/fixtures/collection/testorg/testcol/roles/my_first_role/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: localhost + remote_user: root + roles: + - my_first_role diff --git a/tests/fixtures/collection/testorg/testcol/roles/my_first_role/vars/main.yml b/tests/fixtures/collection/testorg/testcol/roles/my_first_role/vars/main.yml new file mode 100644 index 00000000..017705ee --- /dev/null +++ b/tests/fixtures/collection/testorg/testcol/roles/my_first_role/vars/main.yml @@ -0,0 +1,2 @@ +--- +# vars file for my_first_role From 9d13e02b38fc76cb075936dd422ac28b6dceae6d Mon Sep 17 00:00:00 2001 From: shatakshiiii Date: Fri, 1 Mar 2024 21:38:49 +0530 Subject: [PATCH 3/9] Introduce .prettierignore --- .prettierignore | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .prettierignore diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000..fead6a84 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,3 @@ +# Stuff we don't want prettier to ever to look into +tests/fixtures/collection/testorg/testcol/playbooks/ +tests/fixtures/collection/testorg/testcol/roles/ From e1310914b9e993b50211c59ad13a20c7e637bbb7 Mon Sep 17 00:00:00 2001 From: shatakshiiii Date: Wed, 6 Mar 2024 13:13:34 +0530 Subject: [PATCH 4/9] Address review changes --- .../playbooks/first_playbook_ext.yml.j2 | 18 ++++++++---------- .../playbooks/update_servers.yml.j2 | 8 ++++---- .../roles/my_first_role/defaults/main.yml | 2 -- .../roles/my_first_role/handlers/main.yml | 2 -- .../roles/my_first_role/tasks/main.yml | 2 -- .../roles/my_first_role/tests/test.yml | 5 ----- .../roles/my_first_role/vars/main.yml | 2 -- .../roles/{my_first_role => run}/README.md.j2 | 3 +++ .../new_collection/roles/run/defaults/main.yml | 2 ++ .../new_collection/roles/run/handlers/main.yml | 2 ++ .../{my_first_role => run}/meta/main.yml.j2 | 2 +- .../new_collection/roles/run/tasks/main.yml | 2 ++ .../{my_first_role => run}/tests/inventory | 0 .../new_collection/roles/run/vars/main.yml | 2 ++ .../testcol/playbooks/first_playbook_ext.yml | 18 ++++++++---------- .../testcol/playbooks/update_servers.yml | 8 ++++---- .../roles/my_first_role/defaults/main.yml | 2 -- .../roles/my_first_role/handlers/main.yml | 2 -- .../testcol/roles/my_first_role/tasks/main.yml | 2 -- .../testcol/roles/my_first_role/tests/test.yml | 5 ----- .../testcol/roles/my_first_role/vars/main.yml | 2 -- .../roles/{my_first_role => run}/README.md | 3 +++ .../testcol/roles/run/defaults/main.yml | 2 ++ .../testcol/roles/run/handlers/main.yml | 2 ++ .../roles/{my_first_role => run}/meta/main.yml | 2 +- .../testorg/testcol/roles/run/tasks/main.yml | 2 ++ .../{my_first_role => run}/tests/inventory | 0 .../testorg/testcol/roles/run/vars/main.yml | 2 ++ 28 files changed, 48 insertions(+), 56 deletions(-) delete mode 100644 src/ansible_creator/resources/new_collection/roles/my_first_role/defaults/main.yml delete mode 100644 src/ansible_creator/resources/new_collection/roles/my_first_role/handlers/main.yml delete mode 100644 src/ansible_creator/resources/new_collection/roles/my_first_role/tasks/main.yml delete mode 100644 src/ansible_creator/resources/new_collection/roles/my_first_role/tests/test.yml delete mode 100644 src/ansible_creator/resources/new_collection/roles/my_first_role/vars/main.yml rename src/ansible_creator/resources/new_collection/roles/{my_first_role => run}/README.md.j2 (90%) create mode 100644 src/ansible_creator/resources/new_collection/roles/run/defaults/main.yml create mode 100644 src/ansible_creator/resources/new_collection/roles/run/handlers/main.yml rename src/ansible_creator/resources/new_collection/roles/{my_first_role => run}/meta/main.yml.j2 (98%) create mode 100644 src/ansible_creator/resources/new_collection/roles/run/tasks/main.yml rename src/ansible_creator/resources/new_collection/roles/{my_first_role => run}/tests/inventory (100%) create mode 100644 src/ansible_creator/resources/new_collection/roles/run/vars/main.yml delete mode 100644 tests/fixtures/collection/testorg/testcol/roles/my_first_role/defaults/main.yml delete mode 100644 tests/fixtures/collection/testorg/testcol/roles/my_first_role/handlers/main.yml delete mode 100644 tests/fixtures/collection/testorg/testcol/roles/my_first_role/tasks/main.yml delete mode 100644 tests/fixtures/collection/testorg/testcol/roles/my_first_role/tests/test.yml delete mode 100644 tests/fixtures/collection/testorg/testcol/roles/my_first_role/vars/main.yml rename tests/fixtures/collection/testorg/testcol/roles/{my_first_role => run}/README.md (90%) create mode 100644 tests/fixtures/collection/testorg/testcol/roles/run/defaults/main.yml create mode 100644 tests/fixtures/collection/testorg/testcol/roles/run/handlers/main.yml rename tests/fixtures/collection/testorg/testcol/roles/{my_first_role => run}/meta/main.yml (98%) create mode 100644 tests/fixtures/collection/testorg/testcol/roles/run/tasks/main.yml rename tests/fixtures/collection/testorg/testcol/roles/{my_first_role => run}/tests/inventory (100%) create mode 100644 tests/fixtures/collection/testorg/testcol/roles/run/vars/main.yml diff --git a/src/ansible_creator/resources/new_collection/playbooks/first_playbook_ext.yml.j2 b/src/ansible_creator/resources/new_collection/playbooks/first_playbook_ext.yml.j2 index 0aba277b..d73d076e 100644 --- a/src/ansible_creator/resources/new_collection/playbooks/first_playbook_ext.yml.j2 +++ b/src/ansible_creator/resources/new_collection/playbooks/first_playbook_ext.yml.j2 @@ -1,29 +1,27 @@ {% raw %}--- - name: Network Getting Started First Playbook Extended - connection: ansible.netcommon.network_cli gather_facts: false hosts: all tasks: - - name: Get config for VyOS devices - vyos.vyos.vyos_facts: + - name: Get config for IOS devices + cisco.ios.ios_facts: gather_subset: all - name: Display the config - debug: + ansible.builtin.debug: msg: "The hostname is {{ ansible_net_hostname }} and the OS is {{ ansible_net_version }}" - name: Update the hostname - vyos.vyos.vyos_config: - backup: yes + cisco.ios.ios_config: lines: - - set system host-name vyos-changed + - hostname ios-changed - - name: Get changed config for VyOS devices - vyos.vyos.vyos_facts: + - name: Get changed config for IOS devices + cisco.ios.ios_facts: gather_subset: all - name: Display the changed config - debug: + ansible.builtin.debug: msg: "The new hostname is {{ ansible_net_hostname }} and the OS is {{ ansible_net_version }}" {%- endraw %} diff --git a/src/ansible_creator/resources/new_collection/playbooks/update_servers.yml.j2 b/src/ansible_creator/resources/new_collection/playbooks/update_servers.yml.j2 index 13a7ac42..0679b83a 100644 --- a/src/ansible_creator/resources/new_collection/playbooks/update_servers.yml.j2 +++ b/src/ansible_creator/resources/new_collection/playbooks/update_servers.yml.j2 @@ -4,10 +4,10 @@ become: true tasks: - - name: Ensure apache is at the latest version + - name: Ensure apache is at the present version ansible.builtin.yum: name: httpd - state: latest + state: present - name: Write the apache config file ansible.builtin.template: src: /srv/httpd.j2 @@ -19,10 +19,10 @@ become: true tasks: - - name: Ensure postgresql is at the latest version + - name: Ensure postgresql is at the present version ansible.builtin.yum: name: postgresql - state: latest + state: present - name: Ensure that postgresql is started ansible.builtin.service: name: postgresql diff --git a/src/ansible_creator/resources/new_collection/roles/my_first_role/defaults/main.yml b/src/ansible_creator/resources/new_collection/roles/my_first_role/defaults/main.yml deleted file mode 100644 index d7044342..00000000 --- a/src/ansible_creator/resources/new_collection/roles/my_first_role/defaults/main.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- -# defaults file for my_first_role diff --git a/src/ansible_creator/resources/new_collection/roles/my_first_role/handlers/main.yml b/src/ansible_creator/resources/new_collection/roles/my_first_role/handlers/main.yml deleted file mode 100644 index 6d962c8d..00000000 --- a/src/ansible_creator/resources/new_collection/roles/my_first_role/handlers/main.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- -# handlers file for my_first_role diff --git a/src/ansible_creator/resources/new_collection/roles/my_first_role/tasks/main.yml b/src/ansible_creator/resources/new_collection/roles/my_first_role/tasks/main.yml deleted file mode 100644 index 4252735e..00000000 --- a/src/ansible_creator/resources/new_collection/roles/my_first_role/tasks/main.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- -# tasks file for my_first_role diff --git a/src/ansible_creator/resources/new_collection/roles/my_first_role/tests/test.yml b/src/ansible_creator/resources/new_collection/roles/my_first_role/tests/test.yml deleted file mode 100644 index 69002992..00000000 --- a/src/ansible_creator/resources/new_collection/roles/my_first_role/tests/test.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -- hosts: localhost - remote_user: root - roles: - - my_first_role diff --git a/src/ansible_creator/resources/new_collection/roles/my_first_role/vars/main.yml b/src/ansible_creator/resources/new_collection/roles/my_first_role/vars/main.yml deleted file mode 100644 index 017705ee..00000000 --- a/src/ansible_creator/resources/new_collection/roles/my_first_role/vars/main.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- -# vars file for my_first_role diff --git a/src/ansible_creator/resources/new_collection/roles/my_first_role/README.md.j2 b/src/ansible_creator/resources/new_collection/roles/run/README.md.j2 similarity index 90% rename from src/ansible_creator/resources/new_collection/roles/my_first_role/README.md.j2 rename to src/ansible_creator/resources/new_collection/roles/run/README.md.j2 index 225dd44b..912435ac 100644 --- a/src/ansible_creator/resources/new_collection/roles/my_first_role/README.md.j2 +++ b/src/ansible_creator/resources/new_collection/roles/run/README.md.j2 @@ -27,9 +27,12 @@ Including an example of how to use your role (for instance, with variables passe roles: - { role: username.rolename, x: 42 } +Another way to consume this role would be: + License ------- +# TO-DO: Update the license to the one you want to use (delete this line after setting the license) BSD Author Information diff --git a/src/ansible_creator/resources/new_collection/roles/run/defaults/main.yml b/src/ansible_creator/resources/new_collection/roles/run/defaults/main.yml new file mode 100644 index 00000000..9d7cdbec --- /dev/null +++ b/src/ansible_creator/resources/new_collection/roles/run/defaults/main.yml @@ -0,0 +1,2 @@ +--- +# defaults file for run diff --git a/src/ansible_creator/resources/new_collection/roles/run/handlers/main.yml b/src/ansible_creator/resources/new_collection/roles/run/handlers/main.yml new file mode 100644 index 00000000..f3643bab --- /dev/null +++ b/src/ansible_creator/resources/new_collection/roles/run/handlers/main.yml @@ -0,0 +1,2 @@ +--- +# handlers file for run diff --git a/src/ansible_creator/resources/new_collection/roles/my_first_role/meta/main.yml.j2 b/src/ansible_creator/resources/new_collection/roles/run/meta/main.yml.j2 similarity index 98% rename from src/ansible_creator/resources/new_collection/roles/my_first_role/meta/main.yml.j2 rename to src/ansible_creator/resources/new_collection/roles/run/meta/main.yml.j2 index c572acc9..bc5d639b 100644 --- a/src/ansible_creator/resources/new_collection/roles/my_first_role/meta/main.yml.j2 +++ b/src/ansible_creator/resources/new_collection/roles/run/meta/main.yml.j2 @@ -16,7 +16,7 @@ galaxy_info: # - CC-BY-4.0 license: license (GPL-2.0-or-later, MIT, etc) - min_ansible_version: 2.1 + min_ansible_version: 2.14 # If this a Container Enabled role, provide the minimum Ansible Container version. # min_ansible_container_version: diff --git a/src/ansible_creator/resources/new_collection/roles/run/tasks/main.yml b/src/ansible_creator/resources/new_collection/roles/run/tasks/main.yml new file mode 100644 index 00000000..30395699 --- /dev/null +++ b/src/ansible_creator/resources/new_collection/roles/run/tasks/main.yml @@ -0,0 +1,2 @@ +--- +# tasks file for run diff --git a/src/ansible_creator/resources/new_collection/roles/my_first_role/tests/inventory b/src/ansible_creator/resources/new_collection/roles/run/tests/inventory similarity index 100% rename from src/ansible_creator/resources/new_collection/roles/my_first_role/tests/inventory rename to src/ansible_creator/resources/new_collection/roles/run/tests/inventory diff --git a/src/ansible_creator/resources/new_collection/roles/run/vars/main.yml b/src/ansible_creator/resources/new_collection/roles/run/vars/main.yml new file mode 100644 index 00000000..fd864610 --- /dev/null +++ b/src/ansible_creator/resources/new_collection/roles/run/vars/main.yml @@ -0,0 +1,2 @@ +--- +# vars file for run diff --git a/tests/fixtures/collection/testorg/testcol/playbooks/first_playbook_ext.yml b/tests/fixtures/collection/testorg/testcol/playbooks/first_playbook_ext.yml index 0ab87906..84b1baea 100644 --- a/tests/fixtures/collection/testorg/testcol/playbooks/first_playbook_ext.yml +++ b/tests/fixtures/collection/testorg/testcol/playbooks/first_playbook_ext.yml @@ -1,28 +1,26 @@ --- - name: Network Getting Started First Playbook Extended - connection: ansible.netcommon.network_cli gather_facts: false hosts: all tasks: - - name: Get config for VyOS devices - vyos.vyos.vyos_facts: + - name: Get config for IOS devices + cisco.ios.ios_facts: gather_subset: all - name: Display the config - debug: + ansible.builtin.debug: msg: "The hostname is {{ ansible_net_hostname }} and the OS is {{ ansible_net_version }}" - name: Update the hostname - vyos.vyos.vyos_config: - backup: yes + cisco.ios.ios_config: lines: - - set system host-name vyos-changed + - hostname ios-changed - - name: Get changed config for VyOS devices - vyos.vyos.vyos_facts: + - name: Get changed config for IOS devices + cisco.ios.ios_facts: gather_subset: all - name: Display the changed config - debug: + ansible.builtin.debug: msg: "The new hostname is {{ ansible_net_hostname }} and the OS is {{ ansible_net_version }}" diff --git a/tests/fixtures/collection/testorg/testcol/playbooks/update_servers.yml b/tests/fixtures/collection/testorg/testcol/playbooks/update_servers.yml index 13a7ac42..0679b83a 100644 --- a/tests/fixtures/collection/testorg/testcol/playbooks/update_servers.yml +++ b/tests/fixtures/collection/testorg/testcol/playbooks/update_servers.yml @@ -4,10 +4,10 @@ become: true tasks: - - name: Ensure apache is at the latest version + - name: Ensure apache is at the present version ansible.builtin.yum: name: httpd - state: latest + state: present - name: Write the apache config file ansible.builtin.template: src: /srv/httpd.j2 @@ -19,10 +19,10 @@ become: true tasks: - - name: Ensure postgresql is at the latest version + - name: Ensure postgresql is at the present version ansible.builtin.yum: name: postgresql - state: latest + state: present - name: Ensure that postgresql is started ansible.builtin.service: name: postgresql diff --git a/tests/fixtures/collection/testorg/testcol/roles/my_first_role/defaults/main.yml b/tests/fixtures/collection/testorg/testcol/roles/my_first_role/defaults/main.yml deleted file mode 100644 index d7044342..00000000 --- a/tests/fixtures/collection/testorg/testcol/roles/my_first_role/defaults/main.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- -# defaults file for my_first_role diff --git a/tests/fixtures/collection/testorg/testcol/roles/my_first_role/handlers/main.yml b/tests/fixtures/collection/testorg/testcol/roles/my_first_role/handlers/main.yml deleted file mode 100644 index 6d962c8d..00000000 --- a/tests/fixtures/collection/testorg/testcol/roles/my_first_role/handlers/main.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- -# handlers file for my_first_role diff --git a/tests/fixtures/collection/testorg/testcol/roles/my_first_role/tasks/main.yml b/tests/fixtures/collection/testorg/testcol/roles/my_first_role/tasks/main.yml deleted file mode 100644 index 4252735e..00000000 --- a/tests/fixtures/collection/testorg/testcol/roles/my_first_role/tasks/main.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- -# tasks file for my_first_role diff --git a/tests/fixtures/collection/testorg/testcol/roles/my_first_role/tests/test.yml b/tests/fixtures/collection/testorg/testcol/roles/my_first_role/tests/test.yml deleted file mode 100644 index 69002992..00000000 --- a/tests/fixtures/collection/testorg/testcol/roles/my_first_role/tests/test.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -- hosts: localhost - remote_user: root - roles: - - my_first_role diff --git a/tests/fixtures/collection/testorg/testcol/roles/my_first_role/vars/main.yml b/tests/fixtures/collection/testorg/testcol/roles/my_first_role/vars/main.yml deleted file mode 100644 index 017705ee..00000000 --- a/tests/fixtures/collection/testorg/testcol/roles/my_first_role/vars/main.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- -# vars file for my_first_role diff --git a/tests/fixtures/collection/testorg/testcol/roles/my_first_role/README.md b/tests/fixtures/collection/testorg/testcol/roles/run/README.md similarity index 90% rename from tests/fixtures/collection/testorg/testcol/roles/my_first_role/README.md rename to tests/fixtures/collection/testorg/testcol/roles/run/README.md index 225dd44b..912435ac 100644 --- a/tests/fixtures/collection/testorg/testcol/roles/my_first_role/README.md +++ b/tests/fixtures/collection/testorg/testcol/roles/run/README.md @@ -27,9 +27,12 @@ Including an example of how to use your role (for instance, with variables passe roles: - { role: username.rolename, x: 42 } +Another way to consume this role would be: + License ------- +# TO-DO: Update the license to the one you want to use (delete this line after setting the license) BSD Author Information diff --git a/tests/fixtures/collection/testorg/testcol/roles/run/defaults/main.yml b/tests/fixtures/collection/testorg/testcol/roles/run/defaults/main.yml new file mode 100644 index 00000000..9d7cdbec --- /dev/null +++ b/tests/fixtures/collection/testorg/testcol/roles/run/defaults/main.yml @@ -0,0 +1,2 @@ +--- +# defaults file for run diff --git a/tests/fixtures/collection/testorg/testcol/roles/run/handlers/main.yml b/tests/fixtures/collection/testorg/testcol/roles/run/handlers/main.yml new file mode 100644 index 00000000..f3643bab --- /dev/null +++ b/tests/fixtures/collection/testorg/testcol/roles/run/handlers/main.yml @@ -0,0 +1,2 @@ +--- +# handlers file for run diff --git a/tests/fixtures/collection/testorg/testcol/roles/my_first_role/meta/main.yml b/tests/fixtures/collection/testorg/testcol/roles/run/meta/main.yml similarity index 98% rename from tests/fixtures/collection/testorg/testcol/roles/my_first_role/meta/main.yml rename to tests/fixtures/collection/testorg/testcol/roles/run/meta/main.yml index c572acc9..bc5d639b 100644 --- a/tests/fixtures/collection/testorg/testcol/roles/my_first_role/meta/main.yml +++ b/tests/fixtures/collection/testorg/testcol/roles/run/meta/main.yml @@ -16,7 +16,7 @@ galaxy_info: # - CC-BY-4.0 license: license (GPL-2.0-or-later, MIT, etc) - min_ansible_version: 2.1 + min_ansible_version: 2.14 # If this a Container Enabled role, provide the minimum Ansible Container version. # min_ansible_container_version: diff --git a/tests/fixtures/collection/testorg/testcol/roles/run/tasks/main.yml b/tests/fixtures/collection/testorg/testcol/roles/run/tasks/main.yml new file mode 100644 index 00000000..30395699 --- /dev/null +++ b/tests/fixtures/collection/testorg/testcol/roles/run/tasks/main.yml @@ -0,0 +1,2 @@ +--- +# tasks file for run diff --git a/tests/fixtures/collection/testorg/testcol/roles/my_first_role/tests/inventory b/tests/fixtures/collection/testorg/testcol/roles/run/tests/inventory similarity index 100% rename from tests/fixtures/collection/testorg/testcol/roles/my_first_role/tests/inventory rename to tests/fixtures/collection/testorg/testcol/roles/run/tests/inventory diff --git a/tests/fixtures/collection/testorg/testcol/roles/run/vars/main.yml b/tests/fixtures/collection/testorg/testcol/roles/run/vars/main.yml new file mode 100644 index 00000000..fd864610 --- /dev/null +++ b/tests/fixtures/collection/testorg/testcol/roles/run/vars/main.yml @@ -0,0 +1,2 @@ +--- +# vars file for run From 654e6f34bb4587a36e0d209ae4bd856adb0d8d9b Mon Sep 17 00:00:00 2001 From: shatakshiiii Date: Thu, 7 Mar 2024 10:47:32 +0530 Subject: [PATCH 5/9] Changes in roles/run/README.md.j2 --- .../new_collection/roles/run/README.md.j2 | 25 +++++++++++++++---- .../testorg/testcol/roles/run/README.md | 25 +++++++++++++++---- 2 files changed, 40 insertions(+), 10 deletions(-) diff --git a/src/ansible_creator/resources/new_collection/roles/run/README.md.j2 b/src/ansible_creator/resources/new_collection/roles/run/README.md.j2 index 912435ac..7764ba7d 100644 --- a/src/ansible_creator/resources/new_collection/roles/run/README.md.j2 +++ b/src/ansible_creator/resources/new_collection/roles/run/README.md.j2 @@ -1,5 +1,5 @@ -Role Name -========= +{{ namespace|capitalize }}.{{ collection_name|capitalize }} Role +======================== A brief description of the role goes here. @@ -23,12 +23,27 @@ 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 } +```yaml +- name: Execute tasks on servers + hosts: servers + roles: + - { role: {{ namespace }}.{{ collection_name }}.run, x: 42 } +``` Another way to consume this role would be: +```yaml +- name: Initialize the run role from {{ namespace }}.{{ collection_name }} + hosts: servers + gather_facts: false + tasks: + - name: Trigger invocation of run role + ansible.builtin.include_role: + name: {{ namespace }}.{{ collection_name }}.run + vars: + run_x: 42 +``` + License ------- diff --git a/tests/fixtures/collection/testorg/testcol/roles/run/README.md b/tests/fixtures/collection/testorg/testcol/roles/run/README.md index 912435ac..8a1132b4 100644 --- a/tests/fixtures/collection/testorg/testcol/roles/run/README.md +++ b/tests/fixtures/collection/testorg/testcol/roles/run/README.md @@ -1,5 +1,5 @@ -Role Name -========= +Testorg.Testcol Role +======================== A brief description of the role goes here. @@ -23,12 +23,27 @@ 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 } +```yaml +- name: Execute tasks on servers + hosts: servers + roles: + - { role: testorg.testcol.run, x: 42 } +``` Another way to consume this role would be: +```yaml +- name: Initialize the run role from testorg.testcol + hosts: servers + gather_facts: false + tasks: + - name: Trigger invocation of run role + ansible.builtin.include_role: + name: testorg.testcol.run + vars: + run_x: 42 +``` + License ------- From c4bdd827618420c653b8c8e291579b9b84fd9032 Mon Sep 17 00:00:00 2001 From: shatakshiiii Date: Fri, 8 Mar 2024 11:53:39 +0530 Subject: [PATCH 6/9] address more changes --- .../resources/new_collection/playbooks/update_servers.yml.j2 | 2 ++ .../resources/new_collection/roles/run/README.md.j2 | 2 +- .../collection/testorg/testcol/playbooks/update_servers.yml | 2 ++ tests/fixtures/collection/testorg/testcol/roles/run/README.md | 2 +- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/ansible_creator/resources/new_collection/playbooks/update_servers.yml.j2 b/src/ansible_creator/resources/new_collection/playbooks/update_servers.yml.j2 index 0679b83a..f896162e 100644 --- a/src/ansible_creator/resources/new_collection/playbooks/update_servers.yml.j2 +++ b/src/ansible_creator/resources/new_collection/playbooks/update_servers.yml.j2 @@ -8,6 +8,7 @@ ansible.builtin.yum: name: httpd state: present + - name: Write the apache config file ansible.builtin.template: src: /srv/httpd.j2 @@ -23,6 +24,7 @@ ansible.builtin.yum: name: postgresql state: present + - name: Ensure that postgresql is started ansible.builtin.service: name: postgresql diff --git a/src/ansible_creator/resources/new_collection/roles/run/README.md.j2 b/src/ansible_creator/resources/new_collection/roles/run/README.md.j2 index 7764ba7d..a8514e54 100644 --- a/src/ansible_creator/resources/new_collection/roles/run/README.md.j2 +++ b/src/ansible_creator/resources/new_collection/roles/run/README.md.j2 @@ -1,4 +1,4 @@ -{{ namespace|capitalize }}.{{ collection_name|capitalize }} Role +{{ namespace|capitalize }}.{{ collection_name|capitalize }} Run Role ======================== A brief description of the role goes here. diff --git a/tests/fixtures/collection/testorg/testcol/playbooks/update_servers.yml b/tests/fixtures/collection/testorg/testcol/playbooks/update_servers.yml index 0679b83a..f896162e 100644 --- a/tests/fixtures/collection/testorg/testcol/playbooks/update_servers.yml +++ b/tests/fixtures/collection/testorg/testcol/playbooks/update_servers.yml @@ -8,6 +8,7 @@ ansible.builtin.yum: name: httpd state: present + - name: Write the apache config file ansible.builtin.template: src: /srv/httpd.j2 @@ -23,6 +24,7 @@ ansible.builtin.yum: name: postgresql state: present + - name: Ensure that postgresql is started ansible.builtin.service: name: postgresql diff --git a/tests/fixtures/collection/testorg/testcol/roles/run/README.md b/tests/fixtures/collection/testorg/testcol/roles/run/README.md index 8a1132b4..2142f77a 100644 --- a/tests/fixtures/collection/testorg/testcol/roles/run/README.md +++ b/tests/fixtures/collection/testorg/testcol/roles/run/README.md @@ -1,4 +1,4 @@ -Testorg.Testcol Role +Testorg.Testcol Run Role ======================== A brief description of the role goes here. From b7022e79a0c1282f591d25a465a08ea3bfa4799d Mon Sep 17 00:00:00 2001 From: shatakshiiii Date: Mon, 11 Mar 2024 11:58:37 +0530 Subject: [PATCH 7/9] more changes --- .../resources/new_collection/roles/run/README.md.j2 | 3 ++- .../new_collection/roles/run/meta/main.yml.j2 | 10 +++++----- .../collection/testorg/testcol/roles/run/README.md | 3 ++- .../collection/testorg/testcol/roles/run/meta/main.yml | 10 +++++----- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/ansible_creator/resources/new_collection/roles/run/README.md.j2 b/src/ansible_creator/resources/new_collection/roles/run/README.md.j2 index a8514e54..ae5496c5 100644 --- a/src/ansible_creator/resources/new_collection/roles/run/README.md.j2 +++ b/src/ansible_creator/resources/new_collection/roles/run/README.md.j2 @@ -27,7 +27,8 @@ Including an example of how to use your role (for instance, with variables passe - name: Execute tasks on servers hosts: servers roles: - - { role: {{ namespace }}.{{ collection_name }}.run, x: 42 } + - role: {{ namespace }}.{{ collection_name }}.run + run_x: 42 ``` Another way to consume this role would be: diff --git a/src/ansible_creator/resources/new_collection/roles/run/meta/main.yml.j2 b/src/ansible_creator/resources/new_collection/roles/run/meta/main.yml.j2 index bc5d639b..61fd0892 100644 --- a/src/ansible_creator/resources/new_collection/roles/run/meta/main.yml.j2 +++ b/src/ansible_creator/resources/new_collection/roles/run/meta/main.yml.j2 @@ -1,7 +1,7 @@ galaxy_info: - author: your name - description: your role description - company: your company (optional) + author: foo + description: {{ namespace|capitalize }}.{{ collection_name|capitalize }} Run Role + company: {{ namespace }} # If the issue tracker for your role is not on github, uncomment the # next line and provide a value @@ -14,9 +14,9 @@ galaxy_info: # - GPL-3.0-only # - Apache-2.0 # - CC-BY-4.0 - license: license (GPL-2.0-or-later, MIT, etc) + license: GPL-2.0-or-later - min_ansible_version: 2.14 + min_ansible_version: "2.14" # If this a Container Enabled role, provide the minimum Ansible Container version. # min_ansible_container_version: diff --git a/tests/fixtures/collection/testorg/testcol/roles/run/README.md b/tests/fixtures/collection/testorg/testcol/roles/run/README.md index 2142f77a..52e364c1 100644 --- a/tests/fixtures/collection/testorg/testcol/roles/run/README.md +++ b/tests/fixtures/collection/testorg/testcol/roles/run/README.md @@ -27,7 +27,8 @@ Including an example of how to use your role (for instance, with variables passe - name: Execute tasks on servers hosts: servers roles: - - { role: testorg.testcol.run, x: 42 } + - role: testorg.testcol.run + run_x: 42 ``` Another way to consume this role would be: diff --git a/tests/fixtures/collection/testorg/testcol/roles/run/meta/main.yml b/tests/fixtures/collection/testorg/testcol/roles/run/meta/main.yml index bc5d639b..c3802c6c 100644 --- a/tests/fixtures/collection/testorg/testcol/roles/run/meta/main.yml +++ b/tests/fixtures/collection/testorg/testcol/roles/run/meta/main.yml @@ -1,7 +1,7 @@ galaxy_info: - author: your name - description: your role description - company: your company (optional) + author: foo + description: Testorg.Testcol Run Role + company: testorg # If the issue tracker for your role is not on github, uncomment the # next line and provide a value @@ -14,9 +14,9 @@ galaxy_info: # - GPL-3.0-only # - Apache-2.0 # - CC-BY-4.0 - license: license (GPL-2.0-or-later, MIT, etc) + license: GPL-2.0-or-later - min_ansible_version: 2.14 + min_ansible_version: "2.14" # If this a Container Enabled role, provide the minimum Ansible Container version. # min_ansible_container_version: From 8ea78688441ba7782629fbdf5d74a5c463c1335b Mon Sep 17 00:00:00 2001 From: shatakshiiii Date: Tue, 12 Mar 2024 09:39:25 +0530 Subject: [PATCH 8/9] rename sample playbooks --- .../{first_playbook_ext.yml.j2 => sample_playbook_1.yml.j2} | 0 .../{update_servers.yml.j2 => sample_playbook_2.yml.j2} | 4 ++-- .../resources/new_collection/roles/run/meta/main.yml.j2 | 2 +- .../{first_playbook_ext.yml => sample_playbook_1.yml} | 0 .../playbooks/{update_servers.yml => sample_playbook_2.yml} | 4 ++-- .../collection/testorg/testcol/roles/run/meta/main.yml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) rename src/ansible_creator/resources/new_collection/playbooks/{first_playbook_ext.yml.j2 => sample_playbook_1.yml.j2} (100%) rename src/ansible_creator/resources/new_collection/playbooks/{update_servers.yml.j2 => sample_playbook_2.yml.j2} (92%) rename tests/fixtures/collection/testorg/testcol/playbooks/{first_playbook_ext.yml => sample_playbook_1.yml} (100%) rename tests/fixtures/collection/testorg/testcol/playbooks/{update_servers.yml => sample_playbook_2.yml} (92%) diff --git a/src/ansible_creator/resources/new_collection/playbooks/first_playbook_ext.yml.j2 b/src/ansible_creator/resources/new_collection/playbooks/sample_playbook_1.yml.j2 similarity index 100% rename from src/ansible_creator/resources/new_collection/playbooks/first_playbook_ext.yml.j2 rename to src/ansible_creator/resources/new_collection/playbooks/sample_playbook_1.yml.j2 diff --git a/src/ansible_creator/resources/new_collection/playbooks/update_servers.yml.j2 b/src/ansible_creator/resources/new_collection/playbooks/sample_playbook_2.yml.j2 similarity index 92% rename from src/ansible_creator/resources/new_collection/playbooks/update_servers.yml.j2 rename to src/ansible_creator/resources/new_collection/playbooks/sample_playbook_2.yml.j2 index f896162e..05630c1d 100644 --- a/src/ansible_creator/resources/new_collection/playbooks/update_servers.yml.j2 +++ b/src/ansible_creator/resources/new_collection/playbooks/sample_playbook_2.yml.j2 @@ -5,7 +5,7 @@ tasks: - name: Ensure apache is at the present version - ansible.builtin.yum: + ansible.builtin.dnf: name: httpd state: present @@ -21,7 +21,7 @@ tasks: - name: Ensure postgresql is at the present version - ansible.builtin.yum: + ansible.builtin.dnf: name: postgresql state: present diff --git a/src/ansible_creator/resources/new_collection/roles/run/meta/main.yml.j2 b/src/ansible_creator/resources/new_collection/roles/run/meta/main.yml.j2 index 61fd0892..73d6efbe 100644 --- a/src/ansible_creator/resources/new_collection/roles/run/meta/main.yml.j2 +++ b/src/ansible_creator/resources/new_collection/roles/run/meta/main.yml.j2 @@ -1,7 +1,7 @@ galaxy_info: author: foo description: {{ namespace|capitalize }}.{{ collection_name|capitalize }} Run Role - company: {{ namespace }} + company: {{ namespace | capitalize }} # If the issue tracker for your role is not on github, uncomment the # next line and provide a value diff --git a/tests/fixtures/collection/testorg/testcol/playbooks/first_playbook_ext.yml b/tests/fixtures/collection/testorg/testcol/playbooks/sample_playbook_1.yml similarity index 100% rename from tests/fixtures/collection/testorg/testcol/playbooks/first_playbook_ext.yml rename to tests/fixtures/collection/testorg/testcol/playbooks/sample_playbook_1.yml diff --git a/tests/fixtures/collection/testorg/testcol/playbooks/update_servers.yml b/tests/fixtures/collection/testorg/testcol/playbooks/sample_playbook_2.yml similarity index 92% rename from tests/fixtures/collection/testorg/testcol/playbooks/update_servers.yml rename to tests/fixtures/collection/testorg/testcol/playbooks/sample_playbook_2.yml index f896162e..05630c1d 100644 --- a/tests/fixtures/collection/testorg/testcol/playbooks/update_servers.yml +++ b/tests/fixtures/collection/testorg/testcol/playbooks/sample_playbook_2.yml @@ -5,7 +5,7 @@ tasks: - name: Ensure apache is at the present version - ansible.builtin.yum: + ansible.builtin.dnf: name: httpd state: present @@ -21,7 +21,7 @@ tasks: - name: Ensure postgresql is at the present version - ansible.builtin.yum: + ansible.builtin.dnf: name: postgresql state: present diff --git a/tests/fixtures/collection/testorg/testcol/roles/run/meta/main.yml b/tests/fixtures/collection/testorg/testcol/roles/run/meta/main.yml index c3802c6c..a6e8b22c 100644 --- a/tests/fixtures/collection/testorg/testcol/roles/run/meta/main.yml +++ b/tests/fixtures/collection/testorg/testcol/roles/run/meta/main.yml @@ -1,7 +1,7 @@ galaxy_info: author: foo description: Testorg.Testcol Run Role - company: testorg + company: Testorg # If the issue tracker for your role is not on github, uncomment the # next line and provide a value From 595a1343452784786396c5805075ffd78ffda120 Mon Sep 17 00:00:00 2001 From: shatakshiiii Date: Tue, 12 Mar 2024 15:15:50 +0530 Subject: [PATCH 9/9] add .keep files --- tests/fixtures/collection/testorg/testcol/roles/run/files/.keep | 0 .../fixtures/collection/testorg/testcol/roles/run/templates/.keep | 0 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 tests/fixtures/collection/testorg/testcol/roles/run/files/.keep create mode 100644 tests/fixtures/collection/testorg/testcol/roles/run/templates/.keep diff --git a/tests/fixtures/collection/testorg/testcol/roles/run/files/.keep b/tests/fixtures/collection/testorg/testcol/roles/run/files/.keep new file mode 100644 index 00000000..e69de29b diff --git a/tests/fixtures/collection/testorg/testcol/roles/run/templates/.keep b/tests/fixtures/collection/testorg/testcol/roles/run/templates/.keep new file mode 100644 index 00000000..e69de29b