From 222a14f6e10ed54e0b22b58a45366b443323aa14 Mon Sep 17 00:00:00 2001 From: joelbirchler <jbirchler@redhat.com> Date: Fri, 28 Feb 2020 20:05:40 +0100 Subject: [PATCH] WIP first attempt at gitlab and tower setup in a workload --- ansible/roles/skylight-ansible-tower/tasks/main.yml | 6 ansible/configs/ansible-skylight/software.yml | 263 ++++++++++++++++++------------------- ansible/roles/agnosticd-workload/tasks/tower.yml | 0 ansible/configs/ansible-skylight/workloads.yml | 10 ansible/roles/agnosticd-workload/tasks/gitlab.yml | 0 ansible/roles/agnosticd-workload/tasks/workload.yml | 6 ansible/configs/ansible-skylight/post_software.yml | 112 ++++++++-------- ansible/roles/agnosticd-workload/defaults/main.yml | 1 8 files changed, 194 insertions(+), 204 deletions(-) diff --git a/ansible/configs/ansible-skylight/post_software.yml b/ansible/configs/ansible-skylight/post_software.yml index e2815b8..7053699 100644 --- a/ansible/configs/ansible-skylight/post_software.yml +++ b/ansible/configs/ansible-skylight/post_software.yml @@ -7,69 +7,69 @@ - debug: msg: "Post-Software tasks Started" -# - name: Copy files to workstation -# hosts: workstations -# tasks: -# - name: Copy Ansible Inventory for this environment -# win_copy: -# src: "{{output_dir}}/hosts-{{ env_type }}-{{ guid }}" -# dest: "C:\\inventory.ini" +- name: Copy files to workstation + hosts: workstations + tasks: + - name: Copy Ansible Inventory for this environment + win_copy: + src: "{{output_dir}}/hosts-{{ env_type }}-{{ guid }}" + dest: "C:\\inventory.ini" -# - name: PostSoftware flight-check -# hosts: towers -# gather_facts: false -# become: yes -# tags: -# - post_flight_check -# tasks: -# - name: See if virtualenv is installed -# stat: -# path: venv -# register: virtualenv +- name: PostSoftware flight-check + hosts: towers + gather_facts: false + become: yes + tags: + - post_flight_check + tasks: + - name: See if virtualenv is installed + stat: + path: venv + register: virtualenv -# - name: Setup python virtualenv -# shell: | -# virtualenv venv -# source venv/bin/activate -# pip install ansible requests-credssp pywinrm -# deactivate -# exit 0 -# when: not virtualenv.stat.exists + - name: Setup python virtualenv + shell: | + virtualenv venv + source venv/bin/activate + pip install ansible requests-credssp pywinrm + deactivate + exit 0 + when: not virtualenv.stat.exists -# - name: Test Ansible connectivity to Windows servers -# shell: | -# source venv/bin/activate -# ansible windows -m win_ping -# register: ansible_check -# ignore_errors: true + - name: Test Ansible connectivity to Windows servers + shell: | + source venv/bin/activate + ansible windows -m win_ping + register: ansible_check + ignore_errors: true -# - debug: -# var: ansible_check + - debug: + var: ansible_check -# - fail: -# msg: "Ansible test of tower environment failed" -# when: ansible_check is failed + - fail: + msg: "Ansible test of tower environment failed" + when: ansible_check is failed -# - debug: -# msg: "Post-Software checks completed successfully" + - debug: + msg: "Post-Software checks completed successfully" - name: Include private workloads import_playbook: workloads.yml -# - name: Provisioning final tasks -# hosts: localhost -# connection: local -# gather_facts: false -# become: no -# tasks: -# - name: Report provisioning status -# include_role: -# name: status-report -# vars: -# classroom_status: "Classroom ready" -# status_json: "{{ lookup('template', 'report.j2') }}" -# when: report_status -# - name: Stop SSH/Socks proxy for Windows proxying through bastion -# shell: | -# ssh -i {{ ssh_key | default(infra_ssh_key) | default(ansible_ssh_private_key_file) | default(default_key_name)}} -o "ControlPath=~/.ssh/cp/ssh-%r@%h:%p" -O exit -p 22 {{hostvars[bastion_hostname].ansible_user}}@{{hostvars[bastion_hostname].public_ip_address}} -# when: win_connect_method | d('winrm') == 'psrp' +- name: Provisioning final tasks + hosts: localhost + connection: local + gather_facts: false + become: no + tasks: + - name: Report provisioning status + include_role: + name: status-report + vars: + classroom_status: "Classroom ready" + status_json: "{{ lookup('template', 'report.j2') }}" + when: report_status + - name: Stop SSH/Socks proxy for Windows proxying through bastion + shell: | + ssh -i {{ ssh_key | default(infra_ssh_key) | default(ansible_ssh_private_key_file) | default(default_key_name)}} -o "ControlPath=~/.ssh/cp/ssh-%r@%h:%p" -O exit -p 22 {{hostvars[bastion_hostname].ansible_user}}@{{hostvars[bastion_hostname].public_ip_address}} + when: win_connect_method | d('winrm') == 'psrp' diff --git a/ansible/configs/ansible-skylight/software.yml b/ansible/configs/ansible-skylight/software.yml index 6162e5e..796db95 100644 --- a/ansible/configs/ansible-skylight/software.yml +++ b/ansible/configs/ansible-skylight/software.yml @@ -7,153 +7,144 @@ - debug: msg: "Software tasks Started" -# - name: Report Provisioning Status -# hosts: localhost -# connection: local -# gather_facts: false -# become: no -# tasks: -# - name: Report provisioning status -# include_role: -# name: status-report -# vars: -# classroom_status: "Servers provisioned 1 of 6" -# status_json: "{{ lookup('template', 'report.j2') }}" -# when: report_status -# -# - name: Step 001 software - Configure Active Directory DC -# hosts: activedirectories -# gather_facts: true -# tags: -# - windows-ad-controller -# roles: -# - skylight-windows-ad +- name: Report Provisioning Status + hosts: localhost + connection: local + gather_facts: false + become: no + tasks: + - name: Report provisioning status + include_role: + name: status-report + vars: + classroom_status: "Servers provisioned 1 of 6" + status_json: "{{ lookup('template', 'report.j2') }}" + when: report_status -# - name: Report Provisioning Status -# hosts: localhost -# connection: local -# gather_facts: false -# become: no -# tasks: -# - name: Report provisioning status -# include_role: -# name: status-report -# vars: -# classroom_status: "Active Directory configured 2 of 6" -# status_json: "{{ lookup('template', 'report.j2') }}" -# when: report_status +- name: Step 001 software - Configure Active Directory DC + hosts: activedirectories + gather_facts: true + tags: + - windows-ad-controller + roles: + - skylight-windows-ad -# - name: Step 002 software - Configure Windows Servers -# hosts: -# - windows_servers -# - workstations -# gather_facts: true -# tags: -# - windows-servers -# roles: -# - skylight-windows-common +- name: Report Provisioning Status + hosts: localhost + connection: local + gather_facts: false + become: no + tasks: + - name: Report provisioning status + include_role: + name: status-report + vars: + classroom_status: "Active Directory configured 2 of 6" + status_json: "{{ lookup('template', 'report.j2') }}" + when: report_status -# - name: Report Provisioning Status -# hosts: localhost -# connection: local -# gather_facts: false -# become: no -# tasks: -# - name: Report provisioning status -# include_role: -# name: status-report -# vars: -# classroom_status: "Windows servers configured 3 of 6" -# status_json: "{{ lookup('template', 'report.j2') }}" -# when: report_status +- name: Step 002 software - Configure Windows Servers + hosts: + - windows_servers + - workstations + gather_facts: true + tags: + - windows-servers + roles: + - skylight-windows-common -# - name: Step 003.1 software - Configure GitLab Host -# hosts: gitlab -# become: true -# gather_facts: true -# tags: -# - gitlab -# roles: -# - skylight-linux-common -# - geerlingguy.gitlab +- name: Report Provisioning Status + hosts: localhost + connection: local + gather_facts: false + become: no + tasks: + - name: Report provisioning status + include_role: + name: status-report + vars: + classroom_status: "Windows servers configured 3 of 6" + status_json: "{{ lookup('template', 'report.j2') }}" + when: report_status -# - name: Step 003.2 software - Configure Gitlab Environment -# hosts: gitlab -# become: true -# gather_facts: true -# tags: -# - gitlab -# roles: -# - skylight-gitlab-env +- name: Step 003.1 software - Configure GitLab Host + hosts: gitlab + become: true + gather_facts: true + tags: + - gitlab + roles: + - skylight-linux-common + - geerlingguy.gitlab -# - name: Step 003.3 software - Configure DO417 repos -# hosts: gitlab -# become: False -# gather_facts: False -# tags: -# - gitlab -# roles: -# - skylight-do417-repos +- name: Step 003.2 software - Configure Gitlab Environment + hosts: gitlab + become: true + gather_facts: true + tags: + - gitlab + roles: + - skylight-gitlab-env -# - name: Report Provisioning Status -# hosts: localhost -# connection: local -# gather_facts: false -# become: no -# tasks: -# - name: Report provisioning status -# include_role: -# name: status-report -# vars: -# classroom_status: "Gitlab configured 4 of 6" -# status_json: "{{ lookup('template', 'report.j2') }}" -# when: report_status +- name: Report Provisioning Status + hosts: localhost + connection: local + gather_facts: false + become: no + tasks: + - name: Report provisioning status + include_role: + name: status-report + vars: + classroom_status: "Gitlab configured 4 of 6" + status_json: "{{ lookup('template', 'report.j2') }}" + when: report_status -# - name: Step 004 software - Configure Ansible Tower -# hosts: towers -# become: true -# gather_facts: true -# tags: -# - ansible-tower -# roles: -# - skylight-linux-common -# - skylight-ansible-tower +- name: Step 004 software - Configure Ansible Tower + hosts: towers + become: true + gather_facts: true + tags: + - ansible-tower + roles: + - skylight-linux-common + - skylight-ansible-tower -# - name: Report Provisioning Status -# hosts: localhost -# connection: local -# gather_facts: false -# become: no -# tasks: -# - name: Report provisioning status -# include_role: -# name: status-report -# vars: -# classroom_status: "Ansible Tower configured 5 of 6" -# status_json: "{{ lookup('template', 'report.j2') }}" -# when: report_status +- name: Report Provisioning Status + hosts: localhost + connection: local + gather_facts: false + become: no + tasks: + - name: Report provisioning status + include_role: + name: status-report + vars: + classroom_status: "Ansible Tower configured 5 of 6" + status_json: "{{ lookup('template', 'report.j2') }}" + when: report_status -# - name: Step 005 software - Configure Windows Workstation -# hosts: workstations -# gather_facts: true -# tags: -# - windows-workstation -# roles: -# - skylight-windows-workstation +- name: Step 005 software - Configure Windows Workstation + hosts: workstations + gather_facts: true + tags: + - windows-workstation + roles: + - skylight-windows-workstation -# - name: Report Provisioning Status -# hosts: localhost -# connection: local -# gather_facts: false -# become: no -# tasks: -# - name: Report provisioning status -# include_role: -# name: status-report -# vars: -# classroom_status: "Windows Workstation configured 6 of 6" -# status_json: "{{ lookup('template', 'report.j2') }}" -# when: report_status +- name: Report Provisioning Status + hosts: localhost + connection: local + gather_facts: false + become: no + tasks: + - name: Report provisioning status + include_role: + name: status-report + vars: + classroom_status: "Windows Workstation configured 6 of 6" + status_json: "{{ lookup('template', 'report.j2') }}" + when: report_status - name: Step 00xxxxx software hosts: localhost diff --git a/ansible/configs/ansible-skylight/workloads.yml b/ansible/configs/ansible-skylight/workloads.yml index fe227a3..a22ab68 100644 --- a/ansible/configs/ansible-skylight/workloads.yml +++ b/ansible/configs/ansible-skylight/workloads.yml @@ -10,9 +10,9 @@ include_role: name: "{{ item.tmp }}" vars: - ACTION: "provision" - workload_name: "{{ item.name }}" - git_remote_url: "{{ item.url }}" - git_path: "{{ item.path }}" - git_ssh_key: "{{ item.ssh_key }}" + ACTION: "provision" + workload_name: "{{ item.name }}" + workload_git_url: "{{ item.url }}" + workload_git_path: "{{ item.path }}" + workload_ssh_key: "{{ item.ssh_key }}" loop: "{{ private_workloads }}" \ No newline at end of file diff --git a/ansible/roles/agnosticd-workload/defaults/main.yml b/ansible/roles/agnosticd-workload/defaults/main.yml index 4e706a5..9637227 100644 --- a/ansible/roles/agnosticd-workload/defaults/main.yml +++ b/ansible/roles/agnosticd-workload/defaults/main.yml @@ -1,4 +1,3 @@ --- become_override: False silent: False - diff --git a/ansible/roles/skylight-do417-repos/tasks/main.yml b/ansible/roles/agnosticd-workload/tasks/gitlab.yml similarity index 100% rename from ansible/roles/skylight-do417-repos/tasks/main.yml rename to ansible/roles/agnosticd-workload/tasks/gitlab.yml diff --git a/ansible/roles/skylight-ansible-tower/tasks/create-resources.yml b/ansible/roles/agnosticd-workload/tasks/tower.yml similarity index 100% rename from ansible/roles/skylight-ansible-tower/tasks/create-resources.yml rename to ansible/roles/agnosticd-workload/tasks/tower.yml diff --git a/ansible/roles/agnosticd-workload/tasks/workload.yml b/ansible/roles/agnosticd-workload/tasks/workload.yml index 05112c1..d0714f9 100644 --- a/ansible/roles/agnosticd-workload/tasks/workload.yml +++ b/ansible/roles/agnosticd-workload/tasks/workload.yml @@ -1,11 +1,15 @@ --- -# Implement your Workload deployment tasks here - name: Setting up workload debug: msg: "Setting up workload {{ workload_name }}." when: not silent|bool +- name: Setting up GitLab + include_tasks: gitlab.yml + +- name: Setting up Tower + include_tasks: tower.yml # Leave this as the last task in the playbook. - name: workload tasks complete diff --git a/ansible/roles/skylight-ansible-tower/tasks/main.yml b/ansible/roles/skylight-ansible-tower/tasks/main.yml index 5f91c54..318e56c 100644 --- a/ansible/roles/skylight-ansible-tower/tasks/main.yml +++ b/ansible/roles/skylight-ansible-tower/tasks/main.yml @@ -180,8 +180,4 @@ - name: Update git to credential timeout after 1 day command: git config --global credential.helper 'cache --timeout=86400' -- include_tasks: setup.yml - -# Creation of custom DO417 resources -# TODO: where to get these from? -- include_tasks: create-resources.yml +- include_tasks: setup.yml \ No newline at end of file -- Gitblit v1.9.3