AWX:我无法将我的GitHub存储库与AWX同步,也不知道凭证是指哪一个。
创始人
2024-09-28 10:31:18
0

要将GitHub存储库与AWX同步,您需要使用GitHub凭证。以下是使用AWX API创建GitHub凭证的示例代码:

import requests

# AWX API相关信息
awx_api_url = 'http://awx.example.com/api/v2'
awx_username = 'admin'
awx_password = 'password'

# GitHub凭证信息
github_token = 'your_github_token'
github_organization = 'your_github_organization'
github_repository = 'your_github_repository'

# 创建GitHub凭证
def create_github_credential():
    # 获取AWX认证token
    auth = (awx_username, awx_password)
    response = requests.post(f'{awx_api_url}/authtoken/', auth=auth)
    token = response.json()['token']

    # 创建GitHub凭证
    headers = {
        'Authorization': f'Token {token}',
        'Content-Type': 'application/json'
    }
    data = {
        'name': 'GitHub Credential',
        'description': 'Credential for GitHub',
        'organization': github_organization,
        'credential_type': 42,  # GitHub凭证类型为42
        'inputs': {
            'token': github_token,
            'organization': github_organization,
            'repository': github_repository
        }
    }
    response = requests.post(f'{awx_api_url}/credentials/', headers=headers, json=data)
    response.raise_for_status()
    print('GitHub Credential created successfully.')

# 创建GitHub凭证
create_github_credential()

请确保将示例代码中的awx.example.com替换为您的AWX API URL,并将adminpassword替换为AWX管理员的用户名和密码。另外,将your_github_tokenyour_github_organizationyour_github_repository替换为您的GitHub凭证信息。

运行上述代码后,它将通过AWX API创建一个名为"GitHub Credential"的GitHub凭证,并与指定的GitHub存储库关联。

相关内容

热门资讯

玩家必备攻略!wepoker破... 玩家必备攻略!wepoker破解器有用吗(辅助挂)都是有挂(有挂解密辅助器)1、上手简单,内置详细流...
分享认知!hhpoker真的有... 分享认知!hhpoker真的有透视吗(辅助挂)其实有挂(新版有挂辅助工具)1、每一步都需要思考,不同...
揭秘攻略!智星德州插件最新版本... 揭秘攻略!智星德州插件最新版本更新内容详解(辅助挂)都是是有挂(详细教程辅助技巧)能透视中分为三种模...
实操分享!约局吧德州有挂吗(辅... 实操分享!约局吧德州有挂吗(辅助挂)本来真的有挂(有挂秘籍辅助攻略)1、玩家可以在线上大神俱乐部对游...
玩家攻略!hhpoker作弊码... 玩家攻略!hhpoker作弊码(辅助挂)其实真的有挂(有挂神器辅助技巧)1、点击下载安装,脚本分类一...
查到实测辅助!hhpoker到... 查到实测辅助!hhpoker到底可以作弊吗(辅助挂)切实有挂(竟然有挂辅助软件)1、破解器简单,机器...
推荐十款!wepoker游戏的... 推荐十款!wepoker游戏的安装教程(辅助挂)切实是真的有挂(竟然有挂辅助脚本)1、上手简单,内置...
必备攻略!hhpkoer辅助器... 必备攻略!hhpkoer辅助器(辅助挂)都是真的有挂(揭秘有挂辅助技巧)辅助器是一种具有地方特色的麻...
总算了解!wepoker有辅助... 总算了解!wepoker有辅助器吗(辅助挂)切实存在有挂(有挂方法辅助软件)1、金币登录送、破产送、...
记者爆料!wepoker开辅助... 记者爆料!wepoker开辅助能查到吗(辅助挂)切实是有挂(有挂解密辅助方法)1、游戏颠覆性的策略玩...