内部角色的ansible任务没有被跳过[travis]

时间:2017-04-06 13:49:35

标签: ansible travis-ci

所以我的目录结构大致与此类似

$ tree
.
├── ansible.cfg
├── play.yml
├── roles
│   ├── create_new_user
│   │   ├── defaults
│   │   │   └── main.yml
│   │   └── tasks
│   │       └── main.yml
│   ├── update
│   │   └── tasks
│   │       └── main.yml
└── tests
    ├── inventory
    └── test.yml

在我的.travis.yml文件

---
sudo: required
dist: trusty

language: python
python: "2.7"

# Doc: https://docs.travis-ci.com/user/customizing-the-build#Build-Matrix
env:
  - ANSIBLE_VERSION=2.0.0.0
  - ANSIBLE_VERSION=1.9.6
  - USER=tasdik

install:
  - if [ "$ANSIBLE_VERSION" = "latest" ]; then pip install ansible; else pip install ansible==$ANSIBLE_VERSION; fi
  - if [ "$ANSIBLE_VERSION" = "latest" ]; then pip install ansible-lint; fi

script:
  - ansible-playbook -i tests/inventory tests/test.yml --syntax-check
  - ansible-playbook -i tests/inventory tests/test.yml -vvvv --skip-tags "update, copy_host_ssh_id"

  # check is the user is created or not
  - id -u $USER | grep -q "no" && (echo "user not found" && exit 1) || (echo "user found" && exit 0)

我试图跳过roles/create_new_user/tasks/main.yml

内角色的任务

但任务不会被跳过。有问题的角色

---
- name: Copy .ssh/id_rsa from host box to the remote box for user {{ username }}
  become: true
  copy: 
    src: ~/.ssh/id_rsa.pub
    dest: /home/{{ username }}/.ssh/authorized_keys
    mode: 0600
    owner: "{{ username }}"
    group: "{{ username }}"
  tags:
    - copy_host_ssh_id

tests/test.yml

的内容
---
- hosts: localhost
  connection: local
  become: true
  roles:
    - {role: ../roles/update}
    - {role: ../roles/create_new_user}

Travis build

DOCS

1 个答案:

答案 0 :(得分:1)

删除标记枚举字符串中的空格(由于没有空格,引号也是不必要的):

--skip-tags update,copy_host_ssh_id