连接到 us-gov-west-1 的 GitLab 问题

GitLab issues connecting to us-gov-west-1

今天推出 GitLab.com 更新,我发现使用 Ansible 连接到特定 AWS 区域时出现问题:us-gov-west-1

这很奇怪,因为在我的 CI 工作中,我能够很好地使用 AWS CLI:

CI 构建步骤:

$ aws ec2 describe-instances

输出(截断):

{
    "Reservations": [
        {
            "Instances": [
                {
                    "Monitoring": {
                        "State": "disabled"
                    }, 
                    "PublicDnsName": "ec2-...

构建步骤如下,注意连接不上地区:

CI 构建步骤:

$ ansible-playbook -vvv -i inventory/ec2.py -e ansible_ssh_private_key_file=aws-keypairs/gitlab_keypair.pem playbooks/deploy.yml

输出(截断)

Using /builds/me/my-project/ansible.cfg as config file
ERROR! Attempted to execute "inventory/ec2.py" as inventory script: Inventory script (inventory/ec2.py) had an execution error: region name: us-gov-west-1 likely not supported, or AWS is down.  connection to region failed. 
ERROR: Job failed: exit code 1

还有其他人看到了吗?

今天早上它在工作。知道为什么现在可能会失败吗?

我写了一个 Python 小脚本来更深入地研究 boto。当我用谷歌搜索如何列出区域时,我想起了 boto 2 与 boto 3 的区别。然后,我回顾了我用来安装 boto 的机制。看来问题出在 boto 安装上。

这是我的 .gitlab-ci.yml 文件的错误版本:

image: ansible/ansible:ubuntu1604

test_aws:
  stage: deploy
  before_script:
    - apt-get update
    - apt-get -y install python 
    - apt-get -y install python-boto python-pip
    - pip install awscli
  script:
    - 'aws ec2 describe-instances'

deploy_app:
  stage: deploy
  before_script:
    - apt-get update
    - apt-get -y install python 
    - apt-get -y install python-boto python-pip
    - pip install awscli
  script:
    - 'chmod 400 aws-keypairs/gitlab_keypair.pem'
    - 'ansible-playbook -vvv -i inventory/ec2.py -e ansible_ssh_private_key_file=aws-keypairs/gitlab_keypair.pem playbooks/deploy.yml'

这是固定版本:

image: ansible/ansible:ubuntu1604

all_in_one:
  stage: deploy
  before_script:
    - rm -rf /var/lib/apt/lists/*
    - apt-get update
    - apt-get -y install python python-pip
    - pip install boto==2.48.0
    - pip install awscli
    - pip install ansible==2.2.2.0
  script:
    - 'chmod 400 aws-keypairs/gitlab_keypair.pem'
    - 'aws ec2 describe-instances'
    - 'python ./boto_debug.py'
    - 'ansible-playbook -vvv -i inventory/ec2.py -e ansible_ssh_private_key_file=aws-keypairs/gitlab_keypair.pem playbooks/deploy.yml'

请注意,我从使用 apt-get install 切换到使用 pip install。希望其他人将来会遇到这个 post 并避免使用 apt-get -y install python-boto!

安装 boto