From 80969c59cac0bca642fb5a2eb6e08f62597c5d9c Mon Sep 17 00:00:00 2001 From: c0de Date: Sun, 12 Jan 2025 11:32:20 -0600 Subject: [PATCH] Create docker role --- roles/docker/README.md | 58 ++++++++++++++++++++++++++++++++++ roles/docker/defaults/main.yml | 17 ++++++++++ roles/docker/meta/main.yml | 33 +++++++++++++++++++ roles/docker/tasks/main.yml | 50 +++++++++++++++++++++++++++++ roles/docker/vars/main.yml | 17 ++++++++++ 5 files changed, 175 insertions(+) create mode 100644 roles/docker/README.md create mode 100644 roles/docker/defaults/main.yml create mode 100644 roles/docker/meta/main.yml create mode 100644 roles/docker/tasks/main.yml create mode 100644 roles/docker/vars/main.yml diff --git a/roles/docker/README.md b/roles/docker/README.md new file mode 100644 index 0000000..6633eac --- /dev/null +++ b/roles/docker/README.md @@ -0,0 +1,58 @@ + + +Docker +========= + +Sets up Docker on Ubuntu + +- Installation +- Uninstallation +- Updates + +Requirements +------------ + +- Ubuntu 24.04 (or newer) + +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 +------------ + +- [ubuntu](../ubuntu/README.md) + +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 +------- + +[Apache 2.0](../../LICENSE.md) + +Author Information +------------------ + +- [Code Fox](https://c0de.dev) diff --git a/roles/docker/defaults/main.yml b/roles/docker/defaults/main.yml new file mode 100644 index 0000000..97543b1 --- /dev/null +++ b/roles/docker/defaults/main.yml @@ -0,0 +1,17 @@ +# Copyright 2025 Code Fox +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#SPDX-License-Identifier: MIT-0 +--- +# defaults file for docker diff --git a/roles/docker/meta/main.yml b/roles/docker/meta/main.yml new file mode 100644 index 0000000..33c1551 --- /dev/null +++ b/roles/docker/meta/main.yml @@ -0,0 +1,33 @@ +# Copyright 2025 Code Fox +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +galaxy_info: + author: Code Fox + company: Code Fox LLC + license: Apache-2.0 + + description: | + Manages Docker on Ubuntu + + - Installation + - Uninstallation (TODO) + - Update Version + + min_ansible_version: "2.18" + galaxy_tags: + - docker + - c0defox + +dependencies: + - role: ubuntu diff --git a/roles/docker/tasks/main.yml b/roles/docker/tasks/main.yml new file mode 100644 index 0000000..79a919c --- /dev/null +++ b/roles/docker/tasks/main.yml @@ -0,0 +1,50 @@ +# Copyright 2025 Code Fox +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +--- + +- name: Add Docker GPG key for apt + apt_key: + url: https://download.docker.com/linux/ubuntu/gpg + state: present + +- name: Add Docker Repository + apt_repository: + repo: deb https://download.docker.com/linux/ubuntu focal stable + state: present + +- name: Install Docker + apt: + pkg: + - docker-ce + - docker-ce-cli + - containerd.io + - docker-buildx-plugin + - docker-compose-plugin + state: latest + update_cache: true + +- name: Install Docker Module for Python + pip: + name: docker + +- name: Reload SystemD + ansible.builtin.systemd_service: + daemon_reload: true + +- name: Enable Docker service + ansible.builtin.systemd: + enabled: true + state: started + name: docker diff --git a/roles/docker/vars/main.yml b/roles/docker/vars/main.yml new file mode 100644 index 0000000..b12a7d0 --- /dev/null +++ b/roles/docker/vars/main.yml @@ -0,0 +1,17 @@ +# Copyright 2025 Code Fox +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#SPDX-License-Identifier: MIT-0 +--- +# vars file for docker