From 027b7bd2633bf57e1c49b29329ad61a039a97869 Mon Sep 17 00:00:00 2001 From: clarkzjw Date: Sat, 10 Dec 2022 01:04:49 -0800 Subject: ansible: add debian init --- jinwei.me/config/ansible.cfg | 14 +++++ jinwei.me/config/inventory/aws_ec2.yaml | 7 +++ jinwei.me/config/requirements.yaml | 10 ++++ jinwei.me/config/role.yaml | 3 ++ .../config/roles/debian_init/defaults/main.yaml | 1 + jinwei.me/config/roles/debian_init/tasks/main.yaml | 62 ++++++++++++++++++++++ jinwei.me/config/site.yaml | 3 ++ 7 files changed, 100 insertions(+) create mode 100644 jinwei.me/config/ansible.cfg create mode 100644 jinwei.me/config/inventory/aws_ec2.yaml create mode 100644 jinwei.me/config/requirements.yaml create mode 100644 jinwei.me/config/role.yaml create mode 100644 jinwei.me/config/roles/debian_init/defaults/main.yaml create mode 100644 jinwei.me/config/roles/debian_init/tasks/main.yaml create mode 100644 jinwei.me/config/site.yaml diff --git a/jinwei.me/config/ansible.cfg b/jinwei.me/config/ansible.cfg new file mode 100644 index 0000000..9345045 --- /dev/null +++ b/jinwei.me/config/ansible.cfg @@ -0,0 +1,14 @@ +[defaults] +host_key_checking = False +transport = ssh +remote_user = admin +roles_path = roles +inventory = inventory +force_color = True +interpreter_python = auto_silent + +[connection] +pipelining = True + +[privilege_escalation] +become = True diff --git a/jinwei.me/config/inventory/aws_ec2.yaml b/jinwei.me/config/inventory/aws_ec2.yaml new file mode 100644 index 0000000..100d95b --- /dev/null +++ b/jinwei.me/config/inventory/aws_ec2.yaml @@ -0,0 +1,7 @@ +plugin: aws_ec2 +regions: + - us-west-2 +hostnames: + - tag:Name +compose: + ansible_host: public_ip_address diff --git a/jinwei.me/config/requirements.yaml b/jinwei.me/config/requirements.yaml new file mode 100644 index 0000000..5229cc7 --- /dev/null +++ b/jinwei.me/config/requirements.yaml @@ -0,0 +1,10 @@ +--- +collections: + - name: amazon.aws + version: 3.2.0 + - name: community.general + version: 4.7.0 + - name: ansible.posix + version: 1.3.0 + - name: community.docker + version: 3.2.1 diff --git a/jinwei.me/config/role.yaml b/jinwei.me/config/role.yaml new file mode 100644 index 0000000..ab3fca5 --- /dev/null +++ b/jinwei.me/config/role.yaml @@ -0,0 +1,3 @@ +- hosts: "{{ target }}" + roles: + - role: "{{ role }}" diff --git a/jinwei.me/config/roles/debian_init/defaults/main.yaml b/jinwei.me/config/roles/debian_init/defaults/main.yaml new file mode 100644 index 0000000..685f0b6 --- /dev/null +++ b/jinwei.me/config/roles/debian_init/defaults/main.yaml @@ -0,0 +1 @@ +user_home: /home/clarkzjw diff --git a/jinwei.me/config/roles/debian_init/tasks/main.yaml b/jinwei.me/config/roles/debian_init/tasks/main.yaml new file mode 100644 index 0000000..48e8380 --- /dev/null +++ b/jinwei.me/config/roles/debian_init/tasks/main.yaml @@ -0,0 +1,62 @@ +- name: Disable unattended-upgrades + ansible.builtin.systemd: + name: unattended-upgrades + state: stopped + enabled: false + +- name: install packages + apt: + name: + - apt-transport-https + - build-essential + - ca-certificates + - mariadb-client + - lsb-release + - unzip + - gnupg + - htop + - curl + - zip + - vim + - zsh + - git + update_cache: true + +- name: add user + user: + name: clarkzjw + shell: /usr/bin/zsh + home: "{{ user_home }}" + system: true + +- name: Add Docker GPG apt Key + apt_key: + url: https://download.docker.com/linux/debian/gpg + keyring: /etc/apt/trusted.gpg.d/docker.gpg + state: present + +- name: Add Docker Repository + apt_repository: + repo: deb [arch=amd64 signed-by=/etc/apt/trusted.gpg.d/docker.gpg] https://download.docker.com/linux/debian {{ ansible_distribution_release | lower }} stable + state: present + +- name: Update apt and install docker-ce + apt: + name: + - docker-ce + - docker-ce-cli + - containerd.io + - docker-compose-plugin + state: latest + update_cache: true + +- name: enable docker service + systemd: + name: docker + enabled: true + daemon_reload: true + +- name: Clean unneeded packages + ansible.builtin.apt: + autoremove: true + purge: true diff --git a/jinwei.me/config/site.yaml b/jinwei.me/config/site.yaml new file mode 100644 index 0000000..3dbcc71 --- /dev/null +++ b/jinwei.me/config/site.yaml @@ -0,0 +1,3 @@ +- hosts: jinwei-me + roles: + - role: debian_init -- cgit v1.2.3