diff --git a/.ansible-lint b/.ansible-lint new file mode 100644 index 0000000..b6d3809 --- /dev/null +++ b/.ansible-lint @@ -0,0 +1,5 @@ +skip_list: + - yaml[colons] + - yaml[empty-lines] + - yaml[line-length] + - no-changed-when diff --git a/.drone.env b/.drone.env new file mode 100644 index 0000000..3e0aeac --- /dev/null +++ b/.drone.env @@ -0,0 +1,3 @@ +export ANSIBLE_LINT_EXCLUSION="--exclude collections/ansible_collections --exclude .gitea" +export ANSIBLE_INVENTORY="-i 127.0.0.1, --connection=local" +export ANSIBLE_PLAYBOOK="baseos.yml" diff --git a/.drone.yml b/.drone.yml index 0483d9e..7a1cf9d 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,16 +1,7 @@ --- kind: pipeline type: docker -name: run_ansible_tests_centos9 - -global-variables: - ansible_image : &ansible_image "gitea.thezengarden.net/podman/ansible-dev/centos9:release-34" - ansible_inventory : &ansible_inventory "-i 127.0.0.1, --connection=local" - ansible_playbook : &ansible_playbook "baseos.yml" - -environment: - ANSIBLE_INVENTORY : *ansible_inventory - ANSIBLE_PLAYBOOK : *ansible_playbook +name: CentOS_9-Ansible-Pipeline trigger: branch: @@ -20,41 +11,36 @@ trigger: steps: - name: "ansible_environment_verify" - image: *ansible_image + image: gitea.thezengarden.net/podman/ansible-dev/centos9:release commands: + - . ./.drone.env + - env - git log -1 - ansible --version - ansible-lint --version - name: "ansible_galaxy_requirements" - image: *ansible_image + image: gitea.thezengarden.net/podman/ansible-dev/centos9:release commands: - ansible-galaxy install -r requirements.yml - name: "ansible_lint" - image: *ansible_image + image: gitea.thezengarden.net/podman/ansible-dev/centos9:release commands: - - ansible-lint --offline + - . ./.drone.env + - ansible-lint --offline $ANSIBLE_LINT_EXCLUSION - name: "ansible_playbook_execution" - image: *ansible_image + image: gitea.thezengarden.net/podman/ansible-dev/centos9:release commands: + - . ./.drone.env - ansible-playbook -v $ANSIBLE_INVENTORY $ANSIBLE_PLAYBOOK --- kind: pipeline type: docker -name: run_ansible_tests_fedora39 - -global-variables: - ansible_image : &ansible_image "gitea.thezengarden.net/podman/ansible-dev/fedora39:release-34" - ansible_inventory : &ansible_inventory "-i 127.0.0.1, --connection=local" - ansible_playbook : &ansible_playbook "baseos.yml" - -environment: - ANSIBLE_INVENTORY : *ansible_inventory - ANSIBLE_PLAYBOOK : *ansible_playbook +name: Fedora_39-Ansible-Pipeline trigger: branch: @@ -64,41 +50,36 @@ trigger: steps: - name: "ansible_environment_verify" - image: *ansible_image + image: gitea.thezengarden.net/podman/ansible-dev/fedora39:release commands: + - . ./.drone.env + - env - git log -1 - ansible --version - ansible-lint --version - name: "ansible_galaxy_requirements" - image: *ansible_image + image: gitea.thezengarden.net/podman/ansible-dev/fedora39:release commands: - ansible-galaxy install -r requirements.yml - name: "ansible_lint" - image: *ansible_image + image: gitea.thezengarden.net/podman/ansible-dev/fedora39:release commands: - - ansible-lint --offline + - . ./.drone.env + - ansible-lint --offline $ANSIBLE_LINT_EXCLUSION - name: "ansible_playbook_execution" - image: *ansible_image + image: gitea.thezengarden.net/podman/ansible-dev/fedora39:release commands: + - . ./.drone.env - ansible-playbook -v $ANSIBLE_INVENTORY $ANSIBLE_PLAYBOOK --- kind: pipeline type: docker -name: run_ansible_tests_debian11 - -global-variables: - ansible_image : &ansible_image "gitea.thezengarden.net/podman/ansible-dev/debian11:release-34" - ansible_inventory : &ansible_inventory "-i 127.0.0.1, --connection=local" - ansible_playbook : &ansible_playbook "baseos.yml" - -environment: - ANSIBLE_INVENTORY : *ansible_inventory - ANSIBLE_PLAYBOOK : *ansible_playbook +name: Debian_11-Ansible-Pipeline trigger: branch: @@ -108,41 +89,36 @@ trigger: steps: - name: "ansible_environment_verify" - image: *ansible_image + image: gitea.thezengarden.net/podman/ansible-dev/debian11:release commands: + - . ./.drone.env + - env - git log -1 - ansible --version - ansible-lint --version - name: "ansible_galaxy_requirements" - image: *ansible_image + image: gitea.thezengarden.net/podman/ansible-dev/debian11:release commands: - ansible-galaxy install -r requirements.yml - name: "ansible_lint" - image: *ansible_image + image: gitea.thezengarden.net/podman/ansible-dev/debian11:release commands: - - ansible-lint --offline + - . ./.drone.env + - ansible-lint --offline $ANSIBLE_LINT_EXCLUSION - name: "ansible_playbook_execution" - image: *ansible_image + image: gitea.thezengarden.net/podman/ansible-dev/debian11:release commands: + - . ./.drone.env - ansible-playbook -v $ANSIBLE_INVENTORY $ANSIBLE_PLAYBOOK --- kind: pipeline type: docker -name: run_ansible_tests_debian12 - -global-variables: - ansible_image : &ansible_image "gitea.thezengarden.net/podman/ansible-dev/debian12:release-34" - ansible_inventory : &ansible_inventory "-i 127.0.0.1, --connection=local" - ansible_playbook : &ansible_playbook "baseos.yml" - -environment: - ANSIBLE_INVENTORY : *ansible_inventory - ANSIBLE_PLAYBOOK : *ansible_playbook +name: Debian_12-Ansible-Pipeline trigger: branch: @@ -152,23 +128,27 @@ trigger: steps: - name: "ansible_environment_verify" - image: *ansible_image + image: gitea.thezengarden.net/podman/ansible-dev/debian12:release commands: + - . ./.drone.env + - env - git log -1 - ansible --version - ansible-lint --version - name: "ansible_galaxy_requirements" - image: *ansible_image + image: gitea.thezengarden.net/podman/ansible-dev/debian12:release commands: - ansible-galaxy install -r requirements.yml - name: "ansible_lint" - image: *ansible_image + image: gitea.thezengarden.net/podman/ansible-dev/debian12:release commands: - - ansible-lint --offline + - . ./.drone.env + - ansible-lint --offline $ANSIBLE_LINT_EXCLUSION - name: "ansible_playbook_execution" - image: *ansible_image + image: gitea.thezengarden.net/podman/ansible-dev/debian12:release commands: + - . ./.drone.env - ansible-playbook -v $ANSIBLE_INVENTORY $ANSIBLE_PLAYBOOK diff --git a/.drone.yml.bak b/.drone.yml.bak new file mode 100644 index 0000000..bd37189 --- /dev/null +++ b/.drone.yml.bak @@ -0,0 +1,154 @@ +--- +kind: pipeline +type: docker +name: CentOS_9-Ansible-Pipeline + +environment: + ANSIBLE_INVENTORY : "-i 127.0.0.1, --connection=local" + ANSIBLE_PLAYBOOK : baseos.yml + +trigger: + branch: + exclude: + - main + event: [push] + +steps: + - name: "ansible_environment_verify" + image: gitea.thezengarden.net/podman/ansible-dev/centos9:release + commands: + - git log -1 + - ansible --version + - ansible-lint --version + + - name: "ansible_galaxy_requirements" + image: gitea.thezengarden.net/podman/ansible-dev/centos9:release + commands: + - ansible-galaxy install -r requirements.yml + + - name: "ansible_lint" + image: gitea.thezengarden.net/podman/ansible-dev/centos9:release + commands: + - ansible-lint --offline --exclude collections/ansible_collections/ansible* --exclude collections/ansible_collections/community* --exclude .gitea + + - name: "ansible_playbook_execution" + image: gitea.thezengarden.net/podman/ansible-dev/centos9:release + commands: + - ansible-playbook -v $ANSIBLE_INVENTORY $ANSIBLE_PLAYBOOK + + +--- +kind: pipeline +type: docker +name: Fedora_39-Ansible-Pipeline + +environment: + ANSIBLE_INVENTORY : "-i 127.0.0.1, --connection=local" + ANSIBLE_PLAYBOOK : baseos.yml + +trigger: + branch: + exclude: + - main + event: [push] + +steps: + - name: "ansible_environment_verify" + image: gitea.thezengarden.net/podman/ansible-dev/fedora39:release + commands: + - git log -1 + - ansible --version + - ansible-lint --version + + - name: "ansible_galaxy_requirements" + image: gitea.thezengarden.net/podman/ansible-dev/fedora39:release + commands: + - ansible-galaxy install -r requirements.yml + + - name: "ansible_lint" + image: gitea.thezengarden.net/podman/ansible-dev/fedora39:release + commands: + - ansible-lint --offline --exclude collections/ansible_collections/ansible* --exclude collections/ansible_collections/community* --exclude .gitea + + - name: "ansible_playbook_execution" + image: gitea.thezengarden.net/podman/ansible-dev/fedora39:release + commands: + - ansible-playbook -v $ANSIBLE_INVENTORY $ANSIBLE_PLAYBOOK + + +--- +kind: pipeline +type: docker +name: Debian_11-Ansible-Pipeline + +environment: + ANSIBLE_INVENTORY : "-i 127.0.0.1, --connection=local" + ANSIBLE_PLAYBOOK : baseos.yml + +trigger: + branch: + exclude: + - main + event: [push] + +steps: + - name: "ansible_environment_verify" + image: gitea.thezengarden.net/podman/ansible-dev/debian11:release + commands: + - git log -1 + - ansible --version + - ansible-lint --version + + - name: "ansible_galaxy_requirements" + image: gitea.thezengarden.net/podman/ansible-dev/debian11:release + commands: + - ansible-galaxy install -r requirements.yml + + - name: "ansible_lint" + image: gitea.thezengarden.net/podman/ansible-dev/debian11:release + commands: + - ansible-lint --offline --exclude collections/ansible_collections/ansible* --exclude collections/ansible_collections/community* --exclude .gitea + + - name: "ansible_playbook_execution" + image: gitea.thezengarden.net/podman/ansible-dev/debian11:release + commands: + - ansible-playbook -v $ANSIBLE_INVENTORY $ANSIBLE_PLAYBOOK + + +--- +kind: pipeline +type: docker +name: Debian_12-Ansible-Pipeline + +environment: + ANSIBLE_INVENTORY : "-i 127.0.0.1, --connection=local" + ANSIBLE_PLAYBOOK : baseos.yml + +trigger: + branch: + exclude: + - main + event: [push] + +steps: + - name: "ansible_environment_verify" + image: gitea.thezengarden.net/podman/ansible-dev/debian12:release + commands: + - git log -1 + - ansible --version + - ansible-lint --version + + - name: "ansible_galaxy_requirements" + image: gitea.thezengarden.net/podman/ansible-dev/debian12:release + commands: + - ansible-galaxy install -r requirements.yml + + - name: "ansible_lint" + image: gitea.thezengarden.net/podman/ansible-dev/debian12:release + commands: + - ansible-lint --offline --exclude collections/ansible_collections/ansible* --exclude collections/ansible_collections/community* --exclude .gitea + + - name: "ansible_playbook_execution" + image: gitea.thezengarden.net/podman/ansible-dev/debian12:release + commands: + - ansible-playbook -v $ANSIBLE_INVENTORY $ANSIBLE_PLAYBOOK diff --git a/.gitea/workflows/ansible-test.yml b/.gitea/workflows/ansible-test.yml new file mode 100644 index 0000000..0b0fa42 --- /dev/null +++ b/.gitea/workflows/ansible-test.yml @@ -0,0 +1,37 @@ +name: Ansible Code Pipeline +run-name: ${{ gitea.actor }} is running Ansible Code Pipeline +on: + push: + branches: + - testing + +jobs: + Ansible-Development-Pipeline: + strategy: + matrix: + os: [ ansible-dev-centos9, ansible-dev-fedora39, ansible-dev-debian11, ansible-dev-debian12 ] + runs-on: ${{ matrix.os }} + steps: + - name: Clone repository + uses: actions/checkout@v3 + + - name: Ansible Environment Verify + run: | + git log -1 + ansible --version + ansible-lint --version + + - name: Install Ansible Galaxy Dependencies + run: | + ansible-galaxy install -r requirements.yml + + - name: Run Ansible-Lint + run: | + ansible-lint --offline \ + --exclude collections/ansible_collections/ansible* \ + --exclude collections/ansible_collections/community* \ + --exclude .gitea + + - name: Run Ansible-Playbook + run: | + ansible-playbook -v -i 127.0.0.1, --connection=local baseos.yml diff --git a/.gitignore b/.gitignore index 17494aa..97e6291 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ inventory/* host_vars -ansible.cfg collections/ansible_collections/ +testing.yml diff --git a/ansible.cfg b/ansible.cfg new file mode 100644 index 0000000..47de718 --- /dev/null +++ b/ansible.cfg @@ -0,0 +1,28 @@ +[defaults] +inventory = inventory/hosts +roles_path = roles +collections_path = collections +remote_tmp = /tmp/.ansible-${USER}/tmp +gathering = smart +gather_timeout = 600 +fact_caching = jsonfile +fact_caching_connection = /tmp/.ansible_facts +fact_caching_timeout = 300 +retry_files_enabled = false +forks = 40 +timeout = 30 +host_key_checking = false +display_skipped_hosts = false +bin_ansible_callbacks = true +deprecation_warnings = false +command_warnings = false + +# callback_whitelist is deprecated +# we only include here for backwards compatibility +callback_whitelist = ansible.posix.profile_tasks, ansible.posix.timer +callbacks_enabled = ansible.posix.profile_tasks, ansible.posix.timer + +[ssh_connection] +pipelining = True +ssh_args = -o ControlMaster=auto -o ControlPersist=60s -o PreferredAuthentications=publickey + diff --git a/baseos.yml b/baseos.yml index 5320a26..faa3472 100644 --- a/baseos.yml +++ b/baseos.yml @@ -1,5 +1,5 @@ --- -- name: Deploy a standardized base configuration +- name: Deploy a standardized base configuration to target hosts hosts: all become: true gather_facts: true @@ -10,6 +10,12 @@ tasks: + - name: Debug ansible_virtualization_type + ansible.builtin.debug: + var: ansible_virtualization_type + verbosity: 1 + + - name: Include relevant role(s) ansible.builtin.include_role: name: "{{ item }}" diff --git a/collections/requirements.yml b/requirements.yml similarity index 58% rename from collections/requirements.yml rename to requirements.yml index 62af71e..7ed30b5 100644 --- a/collections/requirements.yml +++ b/requirements.yml @@ -2,9 +2,9 @@ collections: # Our Collections - name: jchristianh.basos - source: https://github.com/jchristianh-ansible-collections/baseos.git + source: https://gitea.thezengarden.net/ansible_collections/ansible-collection-baseos.git type: git - version: main + version: testing # External Collections - name: community.general diff --git a/testing/ansible-test.sh b/testing/ansible-test.sh new file mode 100755 index 0000000..1db0573 --- /dev/null +++ b/testing/ansible-test.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +ansible-playbook -v -i localhost, --connection=local baseos.yml diff --git a/testing/env-test.sh b/testing/env-test.sh new file mode 100755 index 0000000..e5edb50 --- /dev/null +++ b/testing/env-test.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +echo "Which environment to test? (centos9, fedora39, debian11, debian12)" +read test_environment + +CNAME="testing-${test_environment}" +IMG_TAG="release" + +podman pull gitea.thezengarden.net/podman/ansible-dev/${test_environment}:${IMG_TAG} + +podman run -ti --rm --name ${CNAME} --hostname ${CNAME} \ + --cap-add SYS_ADMIN --uts=private \ + -v /home/chris/Development/Ansible/Plays/baseos:/opt/ansible/baseos \ + -v /home/chris/Development/Ansible/Collections/jchristianh/baseos:/opt/ansible/baseos/collections/ansible_collections/jchristianh/baseos \ + gitea.thezengarden.net/podman/ansible-dev/${test_environment}:${IMG_TAG} \ + /bin/bash diff --git a/vars/baseos_vars.yml b/vars/baseos_vars.yml index 9d688d7..c346b04 100644 --- a/vars/baseos_vars.yml +++ b/vars/baseos_vars.yml @@ -1,7 +1,7 @@ --- __baseos_include_roles: - jchristianh.baseos.resolv_conf - - jchristianh.baseos.hostname + # - jchristianh.baseos.hostname - jchristianh.baseos.etc_hosts - jchristianh.baseos.bashrc - jchristianh.baseos.motd