admincontainer
This commit is contained in:
parent
18c950d126
commit
39b4e0286b
@ -1,23 +1,12 @@
|
|||||||
- name: Ensure SSH key is present on remote host
|
- name: Prepare SSH key, clone repos, build image, and run container
|
||||||
hosts: docker_host
|
|
||||||
gather_facts: false
|
|
||||||
tasks:
|
|
||||||
- name: Write SSH private key to /tmp/deploy_key on remote host
|
|
||||||
ansible.builtin.copy:
|
|
||||||
content: "{{ lookup('env', 'SSH_PRIVATE_KEY') }}"
|
|
||||||
dest: "/tmp/deploy_key"
|
|
||||||
mode: '0600'
|
|
||||||
|
|
||||||
- name: Clone repos and run container
|
|
||||||
hosts: docker_host
|
hosts: docker_host
|
||||||
remote_user: ubuntu
|
remote_user: ubuntu
|
||||||
become: yes
|
become: yes
|
||||||
become_method: sudo
|
gather_facts: false
|
||||||
become_user: root
|
|
||||||
vars:
|
vars:
|
||||||
main_br: "{{ lookup('env', 'MAIN_BR') | default('main', true) }}"
|
main_br: "{{ lookup('env', 'MAIN_BR') | default('main', true) }}"
|
||||||
env_br: "{{ lookup('env', 'ENV_BR') | default('main', true) }}"
|
env_br: "{{ lookup('env', 'ENV_BR') | default('main', true) }}"
|
||||||
playbook_file: "{{ lookup('env', 'PLAYBOOK_FILE') | default('base.yaml') }}"
|
|
||||||
base_dir: "/home/ubuntu"
|
base_dir: "/home/ubuntu"
|
||||||
deploy_key_path: "/tmp/deploy_key"
|
deploy_key_path: "/tmp/deploy_key"
|
||||||
repo_core_url: "git@git.felcloud.io:felcloud/ansible_core_init_ansible.git"
|
repo_core_url: "git@git.felcloud.io:felcloud/ansible_core_init_ansible.git"
|
||||||
@ -26,6 +15,12 @@
|
|||||||
repo_env_dir: "{{ base_dir }}/ansible_env_staging"
|
repo_env_dir: "{{ base_dir }}/ansible_env_staging"
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
|
- name: Write SSH private key to remote host
|
||||||
|
ansible.builtin.copy:
|
||||||
|
content: "{{ lookup('env', 'SSH_PRIVATE_KEY') }}"
|
||||||
|
dest: "{{ deploy_key_path }}"
|
||||||
|
mode: '0600'
|
||||||
|
|
||||||
- name: Remove existing core repo
|
- name: Remove existing core repo
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
path: "{{ repo_core_dir }}"
|
path: "{{ repo_core_dir }}"
|
||||||
@ -36,7 +31,7 @@
|
|||||||
path: "{{ repo_env_dir }}"
|
path: "{{ repo_env_dir }}"
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
- name: Clone core repo via SSH
|
- name: Clone core repo using SSH key
|
||||||
ansible.builtin.git:
|
ansible.builtin.git:
|
||||||
repo: "{{ repo_core_url }}"
|
repo: "{{ repo_core_url }}"
|
||||||
dest: "{{ repo_core_dir }}"
|
dest: "{{ repo_core_dir }}"
|
||||||
@ -45,7 +40,7 @@
|
|||||||
environment:
|
environment:
|
||||||
GIT_SSH_COMMAND: "ssh -i {{ deploy_key_path }} -o StrictHostKeyChecking=no -o BatchMode=yes"
|
GIT_SSH_COMMAND: "ssh -i {{ deploy_key_path }} -o StrictHostKeyChecking=no -o BatchMode=yes"
|
||||||
|
|
||||||
- name: Clone env repo via SSH
|
- name: Clone env repo using SSH key
|
||||||
ansible.builtin.git:
|
ansible.builtin.git:
|
||||||
repo: "{{ repo_env_url }}"
|
repo: "{{ repo_env_url }}"
|
||||||
dest: "{{ repo_env_dir }}"
|
dest: "{{ repo_env_dir }}"
|
||||||
@ -54,14 +49,14 @@
|
|||||||
environment:
|
environment:
|
||||||
GIT_SSH_COMMAND: "ssh -i {{ deploy_key_path }} -o StrictHostKeyChecking=no -o BatchMode=yes"
|
GIT_SSH_COMMAND: "ssh -i {{ deploy_key_path }} -o StrictHostKeyChecking=no -o BatchMode=yes"
|
||||||
|
|
||||||
- name: Inject SSH private key into core repo for container use
|
- name: Copy SSH key into core repo for Docker build
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
src: "{{ deploy_key_path }}"
|
src: "{{ deploy_key_path }}"
|
||||||
dest: "{{ repo_core_dir }}/custom_files/id_rsa"
|
dest: "{{ repo_core_dir }}/custom_files/id_rsa"
|
||||||
remote_src: yes
|
remote_src: yes
|
||||||
mode: '0600'
|
mode: '0600'
|
||||||
|
|
||||||
- name: Build the Docker image
|
- name: Build Docker image
|
||||||
community.docker.docker_image:
|
community.docker.docker_image:
|
||||||
name: ansible-pulumi
|
name: ansible-pulumi
|
||||||
tag: local
|
tag: local
|
||||||
@ -72,7 +67,7 @@
|
|||||||
branch: "{{ main_br }}"
|
branch: "{{ main_br }}"
|
||||||
nocache: true
|
nocache: true
|
||||||
|
|
||||||
- name: Run the admin container
|
- name: Run Docker container
|
||||||
community.docker.docker_container:
|
community.docker.docker_container:
|
||||||
name: admin-ansible-run
|
name: admin-ansible-run
|
||||||
image: ansible-pulumi:local
|
image: ansible-pulumi:local
|
||||||
|
Loading…
Reference in New Issue
Block a user