Here is ansible playbook, i given a tag and wanted to use it while i run the playbook, but it will still run the whole playbook
[ansible@centos1 ansible_playbooks]$ cat install_plays.yml
— # install software on multiple hosts
-
hosts: apacheweb
remote_user: ansible
connection: ssh
become: yes
become_method: sudo
gather_facts: yes
vars_files: -
values.property
tasks: -
name: install apache
yum: name={{ apache }} state=latest
tags: -
papa
-
name: copy the httpd.conf
template: src=httpd.conf dest=/etc/httpd/conf
notify: -
restart apache
handlers: -
name: restart apache
service: name=httpd state=restarted enabled=yes -
hosts: appserver
remote_user: ansible
connection: ssh
gather_facts: yes
become: yes
become_method: sudo
vars_files: -
values.property
tasks: -
name: Install telnet
yum: name={{ package }} state=latest -
hosts: debian
remote_user: ansible
connection: ssh
become: yes
become_method: sudo
gather_facts: yes
vars_files: -
values.property
tasks: -
name: Install lynx
apt: name={{ package1 }} state=latest -
hosts: localhost
remote_user: ansible
connection: ssh
gather_facts: yes
become: yes
become_method: sudo
vars_files: -
values.property
tasks: -
name: Install telnet
yum: name={{ package }} state=latest
[ansible@centos1 ansible_playbooks]$
[ansible@centos1 ansible_playbooks]$ ansible-playbook install_plays.yml --tags “papa”
PLAY [apacheweb] ***************************************************************
TASK [setup] *******************************************************************
ok: [centos2.ohari.com]
TASK [install apache] **********************************************************
ok: [centos2.ohari.com]
PLAY [appserver] ***************************************************************
TASK [setup] *******************************************************************
ok: [centos3.ohari.com]
PLAY [debian] ******************************************************************
TASK [setup] *******************************************************************
ok: [ubuntu2.ohari.com]
PLAY [localhost] ***************************************************************
TASK [setup] *******************************************************************
ok: [localhost]
PLAY RECAP *********************************************************************
centos2.ohari.com : ok=2 changed=0 unreachable=0 failed=0
centos3.ohari.com : ok=1 changed=0 unreachable=0 failed=0
localhost : ok=1 changed=0 unreachable=0 failed=0
ubuntu2.ohari.com : ok=1 changed=0 unreachable=0 failed=0
[ansible@centos1 ansible_playbooks]$'
Thank you very much for helping me