{"action":"created","issue":{"url":"https://api.github.com/repos/ansible/ansible/issues/38315","repository_url":"https://api.github.com/repos/ansible/ansible","labels_url":"https://api.github.com/repos/ansible/ansible/issues/38315/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible/issues/38315/comments","events_url":"https://api.github.com/repos/ansible/ansible/issues/38315/events","html_url":"https://github.com/ansible/ansible/issues/38315","id":311459954,"number":38315,"title":"bug about tags function of ansible python api ","user":{"login":"bruceliu01","id":31496772,"avatar_url":"https://avatars0.githubusercontent.com/u/31496772?v=4","gravatar_id":"","url":"https://api.github.com/users/bruceliu01","html_url":"https://github.com/bruceliu01","followers_url":"https://api.github.com/users/bruceliu01/followers","following_url":"https://api.github.com/users/bruceliu01/following{/other_user}","gists_url":"https://api.github.com/users/bruceliu01/gists{/gist_id}","starred_url":"https://api.github.com/users/bruceliu01/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bruceliu01/subscriptions","organizations_url":"https://api.github.com/users/bruceliu01/orgs","repos_url":"https://api.github.com/users/bruceliu01/repos","events_url":"https://api.github.com/users/bruceliu01/events{/privacy}","received_events_url":"https://api.github.com/users/bruceliu01/received_events","type":"User","site_admin":false},"labels":[{"id":835286067,"url":"https://api.github.com/repos/ansible/ansible/labels/affects_2.6","name":"affects_2.6","color":"ededed","default":false},{"id":785271699,"url":"https://api.github.com/repos/ansible/ansible/labels/bug","name":"bug","color":"fbca04","default":true},{"id":636352796,"url":"https://api.github.com/repos/ansible/ansible/labels/support:core","name":"support:core","color":"ededed","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-04-05T03:21:29Z","updated_at":"2018-04-07T10:34:56Z","closed_at":"2018-04-05T14:10:26Z","author_association":"NONE","body":"<!---\r\nVerify first that your issue/request is not already reported on GitHub.\r\nAlso test if the latest release, and devel branch are affected too.\r\nAlways add information AFTER of these html comments.\r\n-->\r\n\r\n##### ISSUE TYPE\r\n<!--- Pick one below and delete the rest -->\r\n - Bug Report\r\n\r\n##### COMPONENT NAME\r\n<!---\r\nInsert below this comment the name of the module, plugin, task or feature.\r\nDo not include extra details here, e.g. \"vyos_command\" not \"the network module vyos_command\" or the full path\r\n-->\r\ntags of ansible python api\r\n\r\n##### ANSIBLE VERSION\r\n<!--- Paste verbatim output from \"ansible --version\" between quotes below -->\r\n```\r\n[root@controller01 ~]# ansible --version\r\nansible 2.3.0.0\r\nconfig file = /etc/ansible/ansible.cfg\r\nconfigured module search path = Default w/o overrides\r\npython version = 2.7.5 (default, Aug  4 2017, 00:39:18) [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)]\r\n```\r\n\r\n##### CONFIGURATION\r\n<!---\r\nIf using Ansible 2.4 or above, paste the results of \"ansible-config dump --only-changed\"\r\nOtherwise, mention any settings you have changed/added/removed in ansible.cfg\r\n(or using the ANSIBLE_* environment variables).\r\n-->\r\n\r\n##### OS / ENVIRONMENT\r\n<!---\r\nMention the OS you are running Ansible from, and the OS you are\r\nmanaging, or say \"N/A\" for anything that is not platform-specific.\r\nAlso mention the specific version of what you are trying to control,\r\ne.g. if this is a network bug the version of firmware on the network device.\r\n-->\r\ncentos python2.7\r\n\r\n##### SUMMARY\r\n<!--- Explain the problem briefly -->\r\nIt can not work right when I use tags feature of ansible python api. Ansible command can work right.\r\n##### STEPS TO REPRODUCE\r\n<!---\r\nFor bugs, show exactly how to reproduce the problem, using a minimal test-case.\r\nFor new features, show how the feature would be used.\r\n-->\r\npython playbook.py\r\nthe following is fragment of playbook.py\r\n```\r\nif __name__ =='__main__':\r\n    play_book=AnsiblePlaybook([\"/home/liux/ntp_server_ip.yml\"], **tags=[\"get\"]**, extra_vars=run_data)\r\n    play_book.run()\r\n    play_book.get_result()\r\n```\r\n<!--- Paste example playbooks or commands between quotes below -->\r\n```yaml\r\n...\r\nplaybook for test\r\n---\r\n- name: NTP server metadata\r\n  hosts: computers\r\n  gather_facts: False\r\n  tags:\r\n    - MetaData\r\n  vars: \r\n    name_cn: \"NTP服务器\"\r\n    name_en: \"NTP Server\"\r\n    role: CONTROLLER_HA\r\n    params:\r\n      - param1:\r\n        name_cn: \"NTP服务器IP\" \r\n        name_en: \"NTP server IP\"\r\n        type: string\r\n        range: null\r\n        default: null\r\n\r\n- name: play with tag \"set\"\r\n  hosts: computers\r\n  gather_facts: False\r\n  tags:\r\n    - set\r\n  tasks:\r\n    - name: copy chrony.conf file \r\n      template:\r\n        src: /home/liux/test\r\n        dest: /home/test\r\n        mode: 0644\r\n        force: yes\r\n    - name: append ntp server\r\n      lineinfile:\r\n        dest: /home/test\r\n        insertafter: \"# insert server\"\r\n        line: \"server {{ item }}\"\r\n      with_items: \"{{ NTP_SERVERS }}\"\r\n\r\n- name: play with tag \"get\"\r\n  hosts: computers\r\n  gather_facts: False\r\n  tags:\r\n    - get\r\n  tasks:\r\n    - shell: \"grep 'server ' /home/test | awk '{print $2}'\"\r\n```\r\n\r\n<!--- You can also paste gist.github.com links for larger files -->\r\n\r\n##### EXPECTED RESULTS\r\n<!--- What did you expect to happen when running the steps above? -->\r\nI wish it just run the play with tag \"set\"\r\n```\r\n===============================================================================\r\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++run the playplay with tag \"set\":\r\n2018-04-05 12:35:45.905530 (delta: 0.063578)         elapsed: 0.067417 ********\r\n===============================================================================\r\n```\r\n##### ACTUAL RESULTS\r\n<!--- What actually happened? If possible run with extra verbosity (-vvvv) -->\r\nIt runs all the play in the playbook\r\n```\r\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++run the playNTP server metadata:\r\n2018-04-05 12:35:45.841896 (delta: 0.003783)         elapsed: 0.003783 ********\r\n===============================================================================\r\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++run the playplay with tag \"set\":\r\n2018-04-05 12:35:45.905530 (delta: 0.063578)         elapsed: 0.067417 ********\r\n===============================================================================\r\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++run the playplay with tag \"get\":\r\n2018-04-05 12:35:45.910583 (delta: 0.005002)         elapsed: 0.07247 *********\r\n===============================================================================\r\n2018-04-05 12:35:45.913458 (delta: 0.002836)         elapsed: 0.075345 ********\r\n2018-04-05 12:35:46.429407 (delta: 0.515907)         elapsed: 0.591294 ********\r\n===============================================================================\r\n```\r\n<!--- Paste verbatim command output between quotes below -->\r\n```\r\n\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/ansible/ansible/issues/comments/379459928","html_url":"https://github.com/ansible/ansible/issues/38315#issuecomment-379459928","issue_url":"https://api.github.com/repos/ansible/ansible/issues/38315","id":379459928,"user":{"login":"bruceliu01","id":31496772,"avatar_url":"https://avatars0.githubusercontent.com/u/31496772?v=4","gravatar_id":"","url":"https://api.github.com/users/bruceliu01","html_url":"https://github.com/bruceliu01","followers_url":"https://api.github.com/users/bruceliu01/followers","following_url":"https://api.github.com/users/bruceliu01/following{/other_user}","gists_url":"https://api.github.com/users/bruceliu01/gists{/gist_id}","starred_url":"https://api.github.com/users/bruceliu01/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bruceliu01/subscriptions","organizations_url":"https://api.github.com/users/bruceliu01/orgs","repos_url":"https://api.github.com/users/bruceliu01/repos","events_url":"https://api.github.com/users/bruceliu01/events{/privacy}","received_events_url":"https://api.github.com/users/bruceliu01/received_events","type":"User","site_admin":false},"created_at":"2018-04-07T10:34:56Z","updated_at":"2018-04-07T10:34:56Z","author_association":"NONE","body":"I have tried the IRC and mail list you gived me. However I can not visit these sites in China.\nDo I have other choice?\nI would describe the bug ,that I proposed on github, to you.\nI have two plays in playbook, one with tag A, and another with tag B. I run the play with ansible python api, and I use the tag function in the options, that is a param for the class PlaybookExecutor.\nIf I run one play one time, it works right. But if I run play with tag A, and run play with tag B at once, it can not work right.\nexpect: run play with tag A; run play with tag B\n\n\nactually: run play with tag A; run play with tag A and run play with tag B\nIt seems that it will run all the plays that are executed before.\n\n\n\n\n发自网易邮箱大师\n\n\nOn 04/5/2018 22:11，Brian Coca<notifications@github.com> wrote：\n\nClosed #38315.\n\n—\nYou are receiving this because you authored the thread.\nReply to this email directly, view it on GitHub, or mute the thread."}}
{"actor":{"display_login":"bruceliu01"}}