From c1f3ca50a58dcf169985e936a8ab66a2b5667ad9 Mon Sep 17 00:00:00 2001 From: Ibrahim Mkusa Date: Wed, 9 Oct 2024 00:02:53 -0400 Subject: [PATCH] install terraform on debian OS v1 --- ansible.cfg | 1 + inventory/inventory | 3 ++ playbooks/terraform/setup_terraform.yml | 47 +++++++++++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 playbooks/terraform/setup_terraform.yml diff --git a/ansible.cfg b/ansible.cfg index 8f32ea9..9a6f5a1 100644 --- a/ansible.cfg +++ b/ansible.cfg @@ -1,3 +1,4 @@ [defaults] inventory=./inventory remote_user="ansible" +roles_path=./roles diff --git a/inventory/inventory b/inventory/inventory index 98f8f11..4980be2 100644 --- a/inventory/inventory +++ b/inventory/inventory @@ -1,3 +1,6 @@ +[docker] +192.168.2.240 + [control] localhost diff --git a/playbooks/terraform/setup_terraform.yml b/playbooks/terraform/setup_terraform.yml new file mode 100644 index 0000000..f475491 --- /dev/null +++ b/playbooks/terraform/setup_terraform.yml @@ -0,0 +1,47 @@ +--- +- name: install terraform on deb/rpm family + hosts: docker + become: yes + tasks: + - name: update cache on debian/rpm family + block: + # assume its a debian host + - name: Assume its apt + ansible.builtin.apt: + update_cache: true + - name: install requirements + ansible.builtin.apt: + pkg: + - gnupg + - software-properties-common + - name: download the key + ansible.builtin.get_url: + url: https://apt.releases.hashicorp.com/gpg + dest: /tmp/hashi_key + + - name: save the key + ansible.builtin.shell: "cat /tmp/hashi_key | gpg --dearmor | sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg > /dev/null" + + - name: Verify the gpg key + ansible.builtin.command: + cmd: gpg --no-default-keyring --keyring /usr/share/keyrings/hashicorp-archive-keyring.gpg --fingerprint + + - name: install terraform + ansible.builtin.apt_repository: + repo: "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com {{ansible_distribution_release}} main" + state: present + filename: hashicorp.list + + - name: Assume its apt + ansible.builtin.apt: + update_cache: true + + - name: Assume its apt + ansible.builtin.apt: + pkg: + - terraform + + - name: verify terraform works + ansible.builtin.command: + cmd: terraform -help +