From 866be44af713f99d5a4f13f1bc1ba8b24460540d Mon Sep 17 00:00:00 2001 From: eneller Date: Fri, 18 Mar 2022 22:42:11 +0100 Subject: [PATCH] add dockerCompose playbook --- group_vars/amd64.yml | 2 ++ group_vars/arm64.yml | 2 ++ group_vars/ubuntu.yml | 2 +- hosts | 8 +++++ playbooks/installDockerCompose.yml | 52 ++++++++++++++++++++++++++++++ 5 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 group_vars/amd64.yml create mode 100644 group_vars/arm64.yml create mode 100644 playbooks/installDockerCompose.yml diff --git a/group_vars/amd64.yml b/group_vars/amd64.yml new file mode 100644 index 0000000..5b6f952 --- /dev/null +++ b/group_vars/amd64.yml @@ -0,0 +1,2 @@ +--- +arch: "amd64" diff --git a/group_vars/arm64.yml b/group_vars/arm64.yml new file mode 100644 index 0000000..bbf06cf --- /dev/null +++ b/group_vars/arm64.yml @@ -0,0 +1,2 @@ +--- +arch: "arm64" diff --git a/group_vars/ubuntu.yml b/group_vars/ubuntu.yml index fb86275..ada5666 100644 --- a/group_vars/ubuntu.yml +++ b/group_vars/ubuntu.yml @@ -1,2 +1,2 @@ --- -ubuntu_package_name_apache: "apache2" +package_name_apache: "apache2" diff --git a/hosts b/hosts index 38e7a93..074692f 100644 --- a/hosts +++ b/hosts @@ -2,5 +2,13 @@ server[1:7]_oracle [home] + [ubuntu] server[1:7]_oracle + +[arm64] +server[2:6:2]_oracle +server7_oracle + +[amd64] +server[1:5:2]_oracle diff --git a/playbooks/installDockerCompose.yml b/playbooks/installDockerCompose.yml new file mode 100644 index 0000000..a1deb0d --- /dev/null +++ b/playbooks/installDockerCompose.yml @@ -0,0 +1,52 @@ +--- +- name: Install Docker + # 'all' is okay here, because the fail task will force the user to specify a limit on the command line, using -l or --limit + hosts: all + become: true + tasks: + - name: checking limit arg + fail: + msg: "you must use -l or --limit - when you really want to use all hosts, use -l 'all'" + when: ansible_limit is not defined + run_once: true + + - name: Install required system packages + apt: + pkg: + - ca-certificates + - curl + - gnupg + - lsb-release + - python3-pip + state: latest + update_cache: yes + + - name: Add Docker GPG Key + apt_key: + url: https://download.docker.com/linux/ubuntu/gpg + state: present + + - name: Add Docker Repository + apt_repository: + repo: "deb [arch={{ arch }}] https://download.docker.com/linux/{{ansible_distribution|lower}} {{ansible_distribution_release}} stable" + state: present + + - name: Install Docker packages + apt: + update_cache: yes + pkg: + - docker-ce + - docker-ce-cli + - containerd.io + + - name: Install docker-compose using pip + pip: + name: + - docker-compose + + - name: add user to docker group + user: + name: "{{ ansible_user_id }}" + groups: + - docker + append: yes