diff --git a/Makefile b/Makefile index 8fafcf2..e6df8cd 100644 --- a/Makefile +++ b/Makefile @@ -20,34 +20,34 @@ thrift_py: ## Builds python code from thrift file rm -rf gen-py dev-build: ## Build and Start the docker-compose.dev.yml - docker-compose -f docker-compose.dev.yml up --build + docker compose -f docker-compose.dev.yml up --build dev-d: ## Build and Start the docker-compose.dev.yml - docker-compose -f docker-compose.dev.yml up -d + docker compose -f docker-compose.dev.yml up -d dev-build-d: ## Build and Start the docker-compose.dev.yml - docker-compose -f docker-compose.dev.yml up --build -d + docker compose -f docker-compose.dev.yml up --build -d dev: ## Build and Start the docker-compose.dev.yml - docker-compose -f docker-compose.dev.yml up + docker compose -f docker-compose.dev.yml up dev-build-bibigrid: ## Build and Start the docker-compose.dev.yml with bibigrid - docker-compose -f docker-compose.dev.bibigrid.yml up --build + docker compose -f docker-compose.dev.bibigrid.yml up --build dev-bibigrid: ## Build and Start the docker-compose.dev.yml with bibigrid - docker-compose -f docker-compose.dev.bibigrid.yml up + docker compose -f docker-compose.dev.bibigrid.yml up dev-build-bibigrid-d: ## Build and Start the docker-compose.dev.yml with bibigrid - docker-compose -f docker-compose.dev.bibigrid.yml up --build -d + docker compose -f docker-compose.dev.bibigrid.yml up --build -d dev-bibigrid-d: ## Build and Start the docker-compose.dev.yml with bibigrid - docker-compose -f docker-compose.dev.bibigrid.yml up -d + docker compose -f docker-compose.dev.bibigrid.yml up -d production: ## Build Release from .env - docker-compose -f docker-compose.yml up --build -d + docker compose -f docker-compose.yml up --build -d production-bibigrid: ## Build Release from .env and with bibigrid - docker-compose -f docker-compose.bibigrid.yml up --build -d + docker compose -f docker-compose.bibigrid.yml up --build -d client_logs: ## Logs from Client docker logs client_portal-client_1 diff --git a/plays/setup_basics.yml b/plays/setup_basics.yml index 9b4fd8c..3ecb881 100644 --- a/plays/setup_basics.yml +++ b/plays/setup_basics.yml @@ -5,11 +5,6 @@ - general_variables.yml - roles: - - role: geerlingguy.docker - tags: always - - pre_tasks: - name: Verify Ansible version assert: @@ -37,18 +32,6 @@ become: no tags: always - - name: Import deadsnake PPA for python3.8 - ansible.builtin.apt_repository: - repo: ppa:deadsnakes/ppa - update_cache: yes - tags: always - - - name: Install python3.8 - apt: - state: latest - name: python3.8 - tags: always - - name: Install python3-pip apt: state: latest @@ -57,7 +40,7 @@ - name: Install list of packages apt: - name: ['libffi-dev', 'libssl-dev', 'jq', 'python3-setuptools'] + name: [ 'libffi-dev', 'libssl-dev', 'jq', 'python3-setuptools' ] state: present update_cache: yes tags: always diff --git a/plays/setup_docker.yml b/plays/setup_docker.yml new file mode 100644 index 0000000..caa2519 --- /dev/null +++ b/plays/setup_docker.yml @@ -0,0 +1,81 @@ +--- +- name: Install Docker on Ubuntu + hosts: gateway + become: true + vars: + arch_mapping: # Map ansible architecture {{ ansible_architecture }} names to Docker's architecture names + x86_64: amd64 + aarch64: arm64 + + tasks: + - name: Update and upgrade all packages to the latest version + ansible.builtin.apt: + update_cache: true + upgrade: dist + cache_valid_time: 3600 + + - name: Install required packages + ansible.builtin.apt: + pkg: + - apt-transport-https + - ca-certificates + - curl + - gnupg + - software-properties-common + + - name: Create directory for Docker's GPG key + ansible.builtin.file: + path: /etc/apt/keyrings + state: directory + mode: '0755' + + - name: Add Docker's official GPG key + ansible.builtin.apt_key: + url: https://download.docker.com/linux/ubuntu/gpg + keyring: /etc/apt/keyrings/docker.gpg + state: present + + - name: Print architecture variables + ansible.builtin.debug: + msg: "Architecture: {{ ansible_architecture }}, Codename: {{ ansible_lsb.codename }}" + + - name: Add Docker repository + ansible.builtin.apt_repository: + repo: >- + deb [arch={{ arch_mapping[ansible_architecture] | default(ansible_architecture) }} + signed-by=/etc/apt/keyrings/docker.gpg] + https://download.docker.com/linux/ubuntu {{ ansible_lsb.codename }} stable + filename: docker + state: present + + - name: Install Docker and related packages + ansible.builtin.apt: + name: "{{ item }}" + state: present + update_cache: true + loop: + - docker-ce + - docker-ce-cli + - containerd.io + - docker-buildx-plugin + - docker-compose-plugin + + - name: Add Docker group + ansible.builtin.group: + name: docker + state: present + + - name: Add user to Docker group + ansible.builtin.user: + name: "{{ ansible_user }}" + groups: docker + append: true + + - name: Enable and start Docker services + ansible.builtin.systemd: + name: "{{ item }}" + enabled: true + state: started + loop: + - docker.service + - containerd.service diff --git a/site.yml b/site.yml index f560271..d154c25 100644 --- a/site.yml +++ b/site.yml @@ -1,2 +1,3 @@ +- import_playbook: plays/setup_docker.yml - import_playbook: plays/setup_basics.yml - import_playbook: plays/setup_client.yml