惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Google DeepMind News
Google DeepMind News
F
Fortinet All Blogs
阮一峰的网络日志
阮一峰的网络日志
Apple Machine Learning Research
Apple Machine Learning Research
爱范儿
爱范儿
WordPress大学
WordPress大学
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
J
Java Code Geeks
罗磊的独立博客
S
SegmentFault 最新的问题
V
V2EX
V
Visual Studio Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
美团技术团队
博客园 - 三生石上(FineUI控件)
Stack Overflow Blog
Stack Overflow Blog
Y
Y Combinator Blog
MyScale Blog
MyScale Blog
D
Docker
Google DeepMind News
Google DeepMind News
Blog — PlanetScale
Blog — PlanetScale
M
Microsoft Research Blog - Microsoft Research
Martin Fowler
Martin Fowler
S
Secure Thoughts
B
Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Recent Announcements
Recent Announcements
MongoDB | Blog
MongoDB | Blog
C
Cisco Blogs
C
CERT Recently Published Vulnerability Notes
T
True Tiger Recordings
GbyAI
GbyAI
P
Proofpoint News Feed
P
Privacy International News Feed
Jina AI
Jina AI
The Cloudflare Blog
I
Intezer
AWS News Blog
AWS News Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
S
Security Archives - TechRepublic
NISL@THU
NISL@THU
The Register - Security
The Register - Security
Recent Commits to openclaw:main
Recent Commits to openclaw:main
P
Palo Alto Networks Blog
S
Schneier on Security
L
LINUX DO - 热门话题
C
CXSECURITY Database RSS Feed - CXSecurity.com
Security Latest
Security Latest
C
Cybersecurity and Infrastructure Security Agency CISA

DEV Community

An open source LLM eval tool with two independent quality signals Using Dashboard Filtering to Get Customer Usage in Seconds from TBs of Data Skills, Java 17, And Theme Accents 4 Hard Lessons on Optimizing AI Coding Agents Arctype: Cross-Platform Database GUI for LLM Artifacts Your robots.txt says GPTBot is welcome. Your server says 403. Organizing How to Use AWS Glue Workflow 5 n8n Automations Every Digital Agency Should Be Running (Bill More, Work Less) Getting Started with TorchGeo — Remote Sensing with PyTorch Designing a Scalable Cross-Platform Appium Framework Google Antigravity 2.0 & Slash Commands Building a Unified Adaptive Learning Intelligence with Gemma 4, Flutter, and Multi-Model Orchestration Looking for beta testers for a £60 server management application The Disk-Pressure Incident That Taught Me to Always Set LimitRanges and Other Lessons from Mirroring EKS Locally. Why AI Should Not Write SQL Against ERP Databases Vibe coding works until it doesn't. The debt is real. Shipping at the Edge: Migrating a Coffee Subscription Platform to Cloudflare Workers Stop Tab-Switching: A Developer's Guide to Color Tools That Actually Fit the Workflow DevOps vs MLOps vs AIOps: What Changes, What Stays, and a Simple Roadmap to Get Started Run Powerful AI Coding Locally on a Normal Laptop 5 n8n Automations Every WooCommerce Store Needs (Save 10+ Hours/Week) What I Learned Building My Own AI Harness Hytale Servers Will Fail Treasure Hunts Until We Fix Our Event Handling Redux in React: Managing Global State Like a Pro Unfreezing Your GitHub Actions: Troubleshooting Stuck Deployments and Protecting Your Git Repo Statistics Unlocking Project Discoverability on GHES: A Key to Software Engineering Productivity When the Cleanup Code Becomes the Project Rockpack 8.0 - A React Scaffolder Built for the Age of AI-Assisted Development Mismanaging the Treasure Hunt Engine in Hytale Servers Will Get You Killed Stop Calling It an AI Assistant. It’s Already Managing Your Company Why Hardcoded Automations Fail AI Agents Why I built a post-quantum signing API (and why JWT is on borrowed time) Weekend Thought: Frontend Build Tools Suffer From Work Amnesia AI Is Changing Engineering Culture More Than We Realize A 10-Line Playwright Trick That Saved Me Hours on Every Sephora Run Everyone Was Focused on Gemini, But Infinite Scaler Was the Real Twister "Gemma 4 Analyzed My Bank Statements – Apparently I 'Have a Problem' with Coffee and Late-Night Apps" #css #webdev #beginners #codenewbie The Hidden Layer Every AI Developer Must Learn AlphaEvolve: Google DeepMind's Gemini-Powered Evolutionary Coding Agent RDS Reserved Instance Pricing: Every Engine, Every Rule, Real Dollar Savings How To Build An AI-Powered MVP Without Burning Your Startup Budget In 2026 Reading a Psychrometric Chart Without Getting Lost LMR-BENCH: Can LLM Agents Reproduce NLP Research Code? (EMNLP 2025) How to turn text into colors (without AI) Building Real-Time Apps in Node.js with Rivalis: WebSockets, Rooms, Actors, and a Binary Wire This Week In React #282 : Security, Fate, TanStack, Redux, Jotai | Hermes-node, Expo, Rozenite, Harness | TC39, Bun, pnpm, npm, Yarn, Node AI Copilot vs AI Agent Architecture - What's Actually Different (And Why It Matters) Smart Contract Security: NEAR's Futures Surge and AI Token Risks Database Maintenance: Tracing Production Incidents to Their Root Cause
将 GitLab 项目同步到 AWX——我的 DevOps 之旅(作者:Sireesha)
Sirisharaju · 2026-05-19 · via DEV Community

如果你一直在关注我的博客系列,你已经知道我已经使用Helm在Kubernetes上部署了Ansible AWX。现在对我来说下一个合乎逻辑的步骤是——我如何在不每次手动上传的情况下把我的playbooks导入AWX?
答案是GitLab。在这篇博客中,我将介绍我如何在虚拟机上安装GitLab,将我的Ansible playbooks推送到它上面,然后将该仓库作为项目同步到AWX——有两种方式:

使用SSH密钥(SCM私钥)——这是我在生产环境中实际使用的
使用通过HTTP的个人访问令牌——适合快速实验环境的搭建

我们开始进入正题。

我们正在构建什么
流程如下:

Ansible服务器 → 推送Playbooks → GitLab(自托管虚拟机) → 同步 → AWX项目 & 模板
一旦设置完成,每次我更新剧本并推送到GitLab,AWX会自动同步并获取最新版本。这就是这套设置真正的强大之处。

第1部分 — 在虚拟机上安装GitLab
我在一台独立的Ubuntu 22.04虚拟机上安装了GitLab。以下是我执行的确切命令:
步骤1 — 安装依赖
sudo apt update
sudo apt install -y curl openssh-server ca-certificates tzdata perl
步骤2 — 添加GitLab仓库并安装
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
sudo apt install gitlab-ce
步骤3 — 配置GitLab
sudo vi /etc/gitlab/gitlab.rb
将外部URL更新为你的虚拟机IP地址:
ruby外部URL(rubyexternal_url) ''http://10.*.*.**'
然后重新配置:
sudo gitlab-ctl reconfigure
步骤4 — 获取初始根密码
sudo cat /etc/gitlab/initial_root_password
打开http://10.*.*.*在浏览器中,使用root和上述密码登录。

提示:首次登录后请立即更改root密码——用户设置 → 密码。

第二部分:创建仓库并推送剧本

在GitLab中,我创建了一个名为:

ansibleawx

的新空白项目。设置为私有后继续。

在Ansible服务器上,我配置了Git:

git config --global user.name "Sireesha"
git config --global user.email "your@email.com"

然后在我的剧本目录中:

cd /etc/ansible

git init
git remote add origin http://ip/ansibleawx.git
git add .
git commit -m "Initial commit - adding ansible playbooks"
git branch -M patches
git push -u origin patches

进入全屏模式 退出全屏模式

我这里使用的是patches分支,因为这是我决定稍后在AWX中跟踪的分支。

这部分的重要性远超表面——分支不匹配会让你吃大亏。

第三部分:使用SSH连接AWX和GitLab(生产方案)

这是我实际正确使用的设置。它更安全,并且避免了令牌过期问题。

生成SSH密钥(在AWX端)
ssh-keygen -t rsa -b 4096 -C "awx@ansible"

然后获取公钥:

cat ~/.ssh/id_rsa.pub

将其添加到GitLab

GitLab → User Settings → SSH Keys → paste key → save

这里没什么复杂的。

创建 AWX 凭证

在 AWX 中:

凭证 → 添加

名称:gitlab-cred
类型:源代码控制
用户名:root
SCM 私钥:粘贴私钥 (~/.ssh/id_rsa)

单击保存。

创建 AWX 项目

AWX → 项目 → 添加

名称:AnsibleAWX
SCM类型: Git
URL: http:///ansibleawx.git
分支: patches
凭据: gitlab-cred

保存后,AWX会自动同步。

当它变绿时,就表示一切就绪。

这时,所有环节都开始顺畅运行。

这正是在我设置的gitlab-cred凭证——从截图中可以看到它显示凭据类型:源码控制,SCM私钥:已加密。

第四部分。替代方案:使用个人访问令牌的HTTP

这是我在实验室环境中使用的更快捷的设置。

在GitLab中创建令牌

GitLab → 设置 → 访问令牌

范围:read_repository

复制它(你只能看到一次)。

添加到AWX

凭据 → 添加

名称:gitlab-http-cred
用户名:root
密码:

保存。

创建项目

和之前一样,但改用此凭据。

它工作正常——只是不如SSH干净或持久。

第5部分——在AWX中创建作业模板

一旦项目同步完成,Playbook 会自动出现在 AWX 中。

于是我创建了一个简单的作业模板:

AWX → 模板 → 添加

  • 名称:Linux 服务器设置 (Linux Server Setup)
  • 作业类型:运行
  • 清单:你的清单
  • 项目:AnsibleAWX
  • Playbook:从下拉菜单中选择
  • 凭证:你的机器凭证

保存并启动。

此时,AWX基本上在运行GitLab中的任何内容。

无需文件复制。无需手动更新。

我在此过程中遇到的错误
错误1 — Git推送分支不匹配

错误:src refspec main不匹配任何内容
修复 — 将分支重命名以匹配你在AWX中设置的内容:
git branch -M patches
git push -u origin patches

错误2 — AWX同步因SSH主机密钥失败

主机密钥验证失败
修复 — 在 AWX Project 设置的 Source Control Options 下,勾选:
✅ 忽略主机检查
错误3 — 作业模板中的剧本下拉列表为空

同步后,创建作业模板时剧本下拉列表为空
.
修复 — 返回你的项目 → 点击同步按钮(环形箭头)→ 等待绿色 → 返回模板。剧本将出现。

在此之前,更新一个 playbook(剧本)需要手动复制文件,并希望 AWX(AWX)已经拥有最新版本。现在我的工作流程是:

Edit playbook → git push to patches branch → AWX syncs → Launch job

进入全屏模式 退出全屏模式

所有内容都受版本控制,可审计且保持一致。

在评论区留下你的问题——乐于解答!
— Sireesha