ansible tower 和gitlab 集成已经用了一阵子了,主要是webhook的问题
因为gitlab的限制,再向tower 发出api调用的时候,token上打上了gitlab-token的head
结果ansible tower不认,以前一直用 用户名:密码@xxx.example.com/api的方式调用
但这样非常不安全,直接暴露了用户密码
需要修改gitlab
cd /opt/gitlab/embedded/service/gitlab-rails/app/services/
vim web_hook_service.rb
修改如下
hash['X-Gitlab-Token'] = Gitlab::Utils.remove_line_breaks(hook.token) if hook.token.present?
hash['Authorization'] = 'Bearer ' + Gitlab::Utils.remove_line_breaks(hook.token) if hook.token.present?
另外修改awx hostname
编辑 /etc/tower/settings.py
TOWER_URL_BASE='http://awx-office.mb.tripadvisor.com'
然后需要更新ansible tower数据库,注册当前服务器
sudo -u awx scl enable rh-python36 rh-postgresql10 "awx-manage provision_instance --hostname=$(hostname)"
sudo -u awx scl enable rh-python36 rh-postgresql10 "awx-manage register_queue --queuename=tower --hostnames=$(hostname)"
最后重启服务
systemctl restart awx-cbreceiver
systemctl restart awx-dispatcher
systemctl restart awx-channels-worker
systemctl restart awx-daphne
systemctl restart awx-web
token的创建
sudo -u awx /usr/bin/scl enable rh-python36 rh-postgresql10 "awx-manage create_oauth2_token --user admin"
网友评论