From ef94a161c564d98475b5c0ac6d96154011c55aa8 Mon Sep 17 00:00:00 2001 From: jonnybravo Date: Tue, 21 Mar 2023 10:39:51 +0100 Subject: [PATCH] added Install gitlab with Ansible and Docker Compose --- gitlab/ansible.cfg | 19 +++++++ gitlab/create_gitlab.yml | 12 ++++ gitlab/group_vars/all/main.yml | 6 ++ gitlab/inv/devel/hosts | 21 +++++++ .../docker_gitlab/files/jenkins_keystore.jks | Bin 0 -> 4400 bytes gitlab/roles/docker_gitlab/tasks/main.yml | 14 +++++ .../templates/docker-compose.yml.j2 | 19 +++++++ gitlab/roles/docker_gitlab/vars/main.yml | 3 + gitlab/roles/prereq_gitlab/README.md | 38 +++++++++++++ gitlab/roles/prereq_gitlab/defaults/main.yml | 8 +++ gitlab/roles/prereq_gitlab/handlers/main.yml | 2 + gitlab/roles/prereq_gitlab/meta/main.yml | 52 ++++++++++++++++++ gitlab/roles/prereq_gitlab/tasks/main.yml | 12 ++++ gitlab/roles/prereq_gitlab/vars/main.yml | 2 + 14 files changed, 208 insertions(+) create mode 100755 gitlab/ansible.cfg create mode 100755 gitlab/create_gitlab.yml create mode 100644 gitlab/group_vars/all/main.yml create mode 100644 gitlab/inv/devel/hosts create mode 100644 gitlab/roles/docker_gitlab/files/jenkins_keystore.jks create mode 100644 gitlab/roles/docker_gitlab/tasks/main.yml create mode 100644 gitlab/roles/docker_gitlab/templates/docker-compose.yml.j2 create mode 100644 gitlab/roles/docker_gitlab/vars/main.yml create mode 100644 gitlab/roles/prereq_gitlab/README.md create mode 100644 gitlab/roles/prereq_gitlab/defaults/main.yml create mode 100644 gitlab/roles/prereq_gitlab/handlers/main.yml create mode 100644 gitlab/roles/prereq_gitlab/meta/main.yml create mode 100644 gitlab/roles/prereq_gitlab/tasks/main.yml create mode 100644 gitlab/roles/prereq_gitlab/vars/main.yml diff --git a/gitlab/ansible.cfg b/gitlab/ansible.cfg new file mode 100755 index 0000000..911dd8b --- /dev/null +++ b/gitlab/ansible.cfg @@ -0,0 +1,19 @@ +[defaults] +inventory = ./inv/ +log_path = ~/.ansible/log_ansible.log +privat_key_file = ~/.ssh/ansible +roles_path = ./roles +retry_files_enabled = true +retry_files_save_path = ~/.ansible/retry-files +force_handlers = true +vault_identity_list = ~/.ansible/.vault-pass +#Gather CONFIG +gathering = smart +fact_caching = yaml +fact_caching_connection = ~/.ansible/fact_caching +fact_caching_timeout = 86400 +callback_plugins = "$(python3 -m ara.setup.callback_plugins)" + +[ara] +api_client = http +api_server = http://127.0.0.1:8000 diff --git a/gitlab/create_gitlab.yml b/gitlab/create_gitlab.yml new file mode 100755 index 0000000..7d786b2 --- /dev/null +++ b/gitlab/create_gitlab.yml @@ -0,0 +1,12 @@ +#! /usr/bin/env ansible-playbook +--- +- name: "Install gitlab in Docker" + gather_facts: true + become: false + hosts: ubuntu + #connection: local + # vars: + # ansible_user: jonnybravo + roles: + - prereq_gitlab + - docker_gitlab diff --git a/gitlab/group_vars/all/main.yml b/gitlab/group_vars/all/main.yml new file mode 100644 index 0000000..878a02c --- /dev/null +++ b/gitlab/group_vars/all/main.yml @@ -0,0 +1,6 @@ +gitlab_dir: + - "/home/{{ansible_user}}/.gitlab" + - "/home/{{ansible_user}}/.gitlab/config" + - "/home/{{ansible_user}}/.gitlab/log" + - "/home/{{ansible_user}}/.gitlab/data" + diff --git a/gitlab/inv/devel/hosts b/gitlab/inv/devel/hosts new file mode 100644 index 0000000..596e4e0 --- /dev/null +++ b/gitlab/inv/devel/hosts @@ -0,0 +1,21 @@ +--- +test: + hosts: + debian: + ubuntu: + rocky: + vars: + ansible_python_interpreter: "/usr/bin/python3" + ansible_ssh_common_args: '-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null' + ansible_user: jonnybravo + ansible_become: true + +Prep: + hosts: + mandan01 + vars: + ansible_python_interpreter: "/usr/bin/python3" + ansible_ssh_common_args: '-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null' + ansible_user: jonnybravo + ansible_become: true + diff --git a/gitlab/roles/docker_gitlab/files/jenkins_keystore.jks b/gitlab/roles/docker_gitlab/files/jenkins_keystore.jks new file mode 100644 index 0000000000000000000000000000000000000000..bc9d81ccfca23b5a19e8ab11ccc5717a31eaa96f GIT binary patch literal 4400 zcma)AS2P?9w>6`SGBSGa#vn$Co~WZlbOsr{*AZQGqjwU~q9%+o(W6BRqa}JLL=c4N zLAfDc21=7>n4u^O=#6aZpCF&Z>TfCl0I z(%mpLndJYH$oL7+WZZvg_P@nUbmxDj$jJb}Vl?Ro7@D*L=J?M9AqC6~CjDaApB-ava{~=P`j7u7f#O8Qef%cjFg#nc-Jv# zvy;aMw@7F*7D!=tQq$(}B8)r5LJW_Xvl{eDAViJDYBLm5o1-JZcRQ7Q?*1Gn8tB~@ zHrLKz(EagVZ(sJK%FYjhG8^%VGn(DHzLC{cyUgID|Zv4rK!n)W+$>3Pi1&cEgw0A*qyv$hQ%6(m-ot;E zf{2*ik1OSWkRMm2vGX$Fy}|Bx{lc0WC$~6yVap)JCn(~RX?bV7%XCYwU#adUU(eaY16xE?>M?_6!E8h_lsD>)WDXWZnI z&%+$FFWAh6>@*xMvMsmu7+uUHHw#h4CbXNO6zKhlJy{`=zvn)!Qmmh(5HTno^z$@# z89K`w#W0L>vNly%<^!81=#oTuX?3jthPf5JVxd_=#Bb3;=fT~8aum_dDE?czz{1T8 zobb#TdBfmDJKlWijz}0$68ISEA@!%fN0)Z9IT#yKzf&S!R=}dXgd6A0r<@Zswt4p` zzrB-R)Kj+IES|)fv+eZ;tkQ#uSwXxfsLAvhkw0$NcGD~vDokt8zptf7HNBm@M&`s? z%k(+0rAy&X$HI6{AN9=&^nTyVcXr}{)0LQ7!x&CQyxE`$_TFnGQg19B>G3IaKl`MK z2?SG;4B#?qU}gTW0C+rI{oQ2m9D?~2&_u~m2qLtOTws$8;-oXs!D7$g;x>VYX&*-o%U(owdFV61t%x`Vg_Zq;VS;BQ);6zAe?l>$wRuqmA zTaTrM7>7KwKFMSnwqr;`&M&cSsKzr-6jWo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4erE$shfeJjFWG^ zg%{rat_P1!h;HUn&^P{KU1`r3)g~i+9zUTG*4X73K;HO<2!08psjXSy#QX?d=dEGD zJcZY*P@bfMl-@+L`yONo4QUNYFa*A|cjyyv1;f4Tdr1Z=e#jNb>k?!5x;(h7xL-~l z7O?FQ%=N{+jDI-!t@6pnV~?f1qf8@w#jBO$vLvd>F}<~>Ko9ax;%JTXJC?MV*}iCc zVl#g>OwE8|$Vf#qY1Yqb-SM-6rtKQnKsx?uq=f28601p-f7upocx6Ze33MaXh!5T( zv{BbZGjMz!qswuy7tZ8=st#p-y=i^Gffs0QQH&p4#1V8iY7T2!$|R)KmKsEZ*fNb+ zm|Pcuu`s3JE_%ob&73Kou&s-q8lG12<28g^1T%dTBGj2rmSJ6+QBfuQ_ED2CB1%2- z{%htGDI!tPz%uy&KeEcj&ZSdL^?+$>Si%Q={Ixw)iq*lRHF5JZKo(J4 zfi}ozBxu;psN;c6SHmX*cOOTp;zscNU^aQ92*ft5j586{4_ZZvVCOeR&{Qc?lkR+8 z5{x5{hZdU%^WR1N3@}HP`(uV%x7G5^cu@6YhDsxjx90RXLj{6!I-#WuqcQ8nD!sUw zaRx1@0fWUxZtT`2_H$t`I2yr`T<71Itp0PSSgpDwU58*bW&0t|5-;N7Nl~2nagKwg zGcApm^1PuF|Lm}GtWb!DS6c(VB|!=Eluaz8`-qSXnSLf0f-OQ>4x?uvSUZj*y7OdBQ& zqxk2G00a=?5pbwUU$NZ?HJI4bG006^vybn#cHBqd_73KEF3?sglFS4&&WpL8h*ujV U&#~Qx%qyV2u<~=6|2jGU0n#-JMF0Q* literal 0 HcmV?d00001 diff --git a/gitlab/roles/docker_gitlab/tasks/main.yml b/gitlab/roles/docker_gitlab/tasks/main.yml new file mode 100644 index 0000000..77aa4e3 --- /dev/null +++ b/gitlab/roles/docker_gitlab/tasks/main.yml @@ -0,0 +1,14 @@ +--- +- name: Template Docker compose + template: + src: docker-compose.yml.j2 + dest: "{{gitlab_dir[0]}}/docker-compose.yml" + owner: "{{ansible_user}}" + group: "{{ansible_user}}" + mode: 0777 + +#- name: deploy Docker Compose stack +# docker_compose: +# project_src: "{{jenkins_dir[0]}}" +# files: +# - docker-compose.yml \ No newline at end of file diff --git a/gitlab/roles/docker_gitlab/templates/docker-compose.yml.j2 b/gitlab/roles/docker_gitlab/templates/docker-compose.yml.j2 new file mode 100644 index 0000000..d49c1a2 --- /dev/null +++ b/gitlab/roles/docker_gitlab/templates/docker-compose.yml.j2 @@ -0,0 +1,19 @@ +version: '3.8' +services: + web: + image: 'gitlab/gitlab-ce:latest' + restart: always + hostname: 'localhost' + container_name: gitlab-ce + environment: + GITLAB_OMNIBUS_CONFIG: | + external_url 'http://{{ansible_host}}:{{web_port}}' + gitlab_rails['gitlab_shell_ssh_port'] = {{ssh_port}} + ports: + - '{{web_port}}:8929' + - '{{ssh_port}}:22' + volumes: + - '{{gitlab_dir[1]}}:/etc/gitlab' + - '{{gitlab_dir[2]}}:/var/log/gitlab' + - '{{gitlab_dir[3]}}:/var/opt/gitlab' + shm_size: '{{shm_size}}' \ No newline at end of file diff --git a/gitlab/roles/docker_gitlab/vars/main.yml b/gitlab/roles/docker_gitlab/vars/main.yml new file mode 100644 index 0000000..cc7b43f --- /dev/null +++ b/gitlab/roles/docker_gitlab/vars/main.yml @@ -0,0 +1,3 @@ +web_port: 8929 +ssh_port: 2222 +shm_size: "1024m" diff --git a/gitlab/roles/prereq_gitlab/README.md b/gitlab/roles/prereq_gitlab/README.md new file mode 100644 index 0000000..225dd44 --- /dev/null +++ b/gitlab/roles/prereq_gitlab/README.md @@ -0,0 +1,38 @@ +Role Name +========= + +A brief description of the role goes here. + +Requirements +------------ + +Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required. + +Role Variables +-------------- + +A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well. + +Dependencies +------------ + +A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles. + +Example Playbook +---------------- + +Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: + + - hosts: servers + roles: + - { role: username.rolename, x: 42 } + +License +------- + +BSD + +Author Information +------------------ + +An optional section for the role authors to include contact information, or a website (HTML is not allowed). diff --git a/gitlab/roles/prereq_gitlab/defaults/main.yml b/gitlab/roles/prereq_gitlab/defaults/main.yml new file mode 100644 index 0000000..0d262d1 --- /dev/null +++ b/gitlab/roles/prereq_gitlab/defaults/main.yml @@ -0,0 +1,8 @@ +--- +# defaults file for roles/prereq-portainer +# portainer direcotorys + +#portainer_dir: +# - "/home/{{ansible_user}}/.portainer" +# - "/home/{{ansible_user}}/.portainer/cert" +# - "/home/{{ansible_user}}/.portainer/data" \ No newline at end of file diff --git a/gitlab/roles/prereq_gitlab/handlers/main.yml b/gitlab/roles/prereq_gitlab/handlers/main.yml new file mode 100644 index 0000000..3134f95 --- /dev/null +++ b/gitlab/roles/prereq_gitlab/handlers/main.yml @@ -0,0 +1,2 @@ +--- +# handlers file for roles/prereq-portainer diff --git a/gitlab/roles/prereq_gitlab/meta/main.yml b/gitlab/roles/prereq_gitlab/meta/main.yml new file mode 100644 index 0000000..c572acc --- /dev/null +++ b/gitlab/roles/prereq_gitlab/meta/main.yml @@ -0,0 +1,52 @@ +galaxy_info: + author: your name + description: your role description + company: your company (optional) + + # If the issue tracker for your role is not on github, uncomment the + # next line and provide a value + # issue_tracker_url: http://example.com/issue/tracker + + # Choose a valid license ID from https://spdx.org - some suggested licenses: + # - BSD-3-Clause (default) + # - MIT + # - GPL-2.0-or-later + # - GPL-3.0-only + # - Apache-2.0 + # - CC-BY-4.0 + license: license (GPL-2.0-or-later, MIT, etc) + + min_ansible_version: 2.1 + + # If this a Container Enabled role, provide the minimum Ansible Container version. + # min_ansible_container_version: + + # + # Provide a list of supported platforms, and for each platform a list of versions. + # If you don't wish to enumerate all versions for a particular platform, use 'all'. + # To view available platforms and versions (or releases), visit: + # https://galaxy.ansible.com/api/v1/platforms/ + # + # platforms: + # - name: Fedora + # versions: + # - all + # - 25 + # - name: SomePlatform + # versions: + # - all + # - 1.0 + # - 7 + # - 99.99 + + galaxy_tags: [] + # List tags for your role here, one per line. A tag is a keyword that describes + # and categorizes the role. Users find roles by searching for tags. Be sure to + # remove the '[]' above, if you add tags to this list. + # + # NOTE: A tag is limited to a single word comprised of alphanumeric characters. + # Maximum 20 tags per role. + +dependencies: [] + # List your role dependencies here, one per line. Be sure to remove the '[]' above, + # if you add dependencies to this list. diff --git a/gitlab/roles/prereq_gitlab/tasks/main.yml b/gitlab/roles/prereq_gitlab/tasks/main.yml new file mode 100644 index 0000000..bc32a04 --- /dev/null +++ b/gitlab/roles/prereq_gitlab/tasks/main.yml @@ -0,0 +1,12 @@ +--- +# tasks file for roles/prereq-portainer +#- name: check assets +# assets: +# +- name: 0 create default direcotorys + file: + path: "{{item}}" + state: directory + owner: "{{ansible_user}}" + group: "{{ansible_user}}" + loop: "{{gitlab_dir}}" diff --git a/gitlab/roles/prereq_gitlab/vars/main.yml b/gitlab/roles/prereq_gitlab/vars/main.yml new file mode 100644 index 0000000..2c439fe --- /dev/null +++ b/gitlab/roles/prereq_gitlab/vars/main.yml @@ -0,0 +1,2 @@ +--- +# vars file for roles/prereq-portainer