1、创建roles目录
mkdir -p ansible_install/{group_vars,roles}
mkdir -p ansible_install/roles/gitlab/{files,handlers,tasks,templates}
![bb97f3c6b018d3234dcfa7891e9ba93b.png](https://i-blog.csdnimg.cn/blog_migrate/2f65d70cc70979248c3729d48d06df32.jpeg)
2、roles基本配置
#cat hosts
[gitlab]
192.168.52.17 ansible_ssh_user=root ansible_ssh_pass=1qaz@WSX gitlab_host=192.168.52.17
#cat roles/gitlab/tasks/main.yml
---
- name: intall software
shell: yum install -y curl policycoreutils openssh-server openssh-clients postfix
- name: systemctl start service
service: name=postfix state=started enabled=yes
- name: Copy gitlab rpm file
copy: src=gitlab-ce-8.0.0-ce.0.el7.x86_64.rpm dest=/tmp
- name: Install gitlab
yum: name=/tmp/gitlab-ce-8.0.0-ce.0.el7.x86_64.rpm state=present
- name: update gitlab config
shell: sed -i "{{ item }}" /etc/gitlab/gitlab.rb
with_items:
- "s#external_url 'http://localhost'#external_url 'http://{{ gitlab_host }}:8081'#g"
- name: gitlab reconfigure
shell: gitlab-ctl reconfigure
- name: start gitlab
shell: gitlab-ctl restart
配置文件检查:
ansible-playbook gitlab_jenkins.yml -i hosts --syntax-check
3、安装过程
ansible-playbook gitlab_jenkins.yml -i hosts
![e70fe50de47faae05fa1b911a8814558.png](https://i-blog.csdnimg.cn/blog_migrate/02409178e747ca300e8be28ebade93e5.jpeg)
如上,安装成功。
4、登陆gitlab验证
访问:http://192.168.52.17:8081
初始账户: root 密码:5iveL!fe
![7dcd1fd4f5c7ba9d7361c54b49c8105e.png](https://i-blog.csdnimg.cn/blog_migrate/15c793ed8de26550b0173ebacac9ca8b.jpeg)