--- -hosts:web become:yes name:"Install and Configure Apache Web server" tasks: -name:"Install Apache Web Server" yum: name:httpd state:latest -name:"Ensure Apache Web Server is Running" service: name:httpd state:started
ERROR! Syntax Error while loading YAML. found atabcharacter that violate indentation The error appears to be in'/etc/ansible/playbooks/apache1.yml': line10, column 1, but may be elsewhere inthefile depending ontheexactsyntaxproblem. The offending line appears to be: state: latest ^ here There appears to be atabcharacteratthestartoftheline.
YAML does not use tabs for formatting. Tabs should be replaced with spaces. For example: - name: update tooling vars: version: 1.2.3 # ^--- there is a tab there. Should be written as: - name: update tooling vars: version: 1.2.3 # ^--- all spaces here.
TASK [Install Apache Web Server] ********************************************************************************* changed: [node2.2g.lab] changed: [node1.2g.lab]
TASK [Ensure Apache Web Server is Running] *********************************************************************** changed: [node1.2g.lab] changed: [node2.2g.lab]
TASK [Install Apache Web Server] ***************************************************************************************** task path: /etc/ansible/playbooks/apache.yml:6 changed: [node2.2g.lab] => {"changed": true, "msg": "Check mode: No changes made, but would have if not in check mod e", "rc": 0, "results": ["Installed: httpd"]} changed: [node1.2g.lab] => {"changed": true, "changes": {"installed": ["httpd"], "updated": []}, "msg": "", "obsolet es": {"urw-fonts": {"dist": "noarch", "repo": "@anaconda", "version": "2.4-16.el7"}}, "rc": 0, "results": []}
TASK [Ensure Apache Web Server is Running] ******************************************************************************* task path: /etc/ansible/playbooks/apache.yml:10 changed: [node1.2g.lab] => {"changed": true, "msg": "Service httpd not found on host, assuming it will exist on full run"} changed: [node2.2g.lab] => {"changed": true, "msg": "Service httpd not found on host, assuming it will exist on full run"} META: ran handlers META: ran handlers
--- -hosts:web become:yes name:"Install a List of Packages on Red Hat Based System" tasks: -name:"Installing a list of packages" yum: name: -curl -httpd -nano -htop
--- -hosts:web become:yes name:"Install a List of Packages on Red Hat Based System" tasks: -name:"Installing a list of packages" yum:name={{item}}state=latest with_items: -curl -httpd -nano -htop
--- -hosts:web become:yes name:"Install a List of Packages on Red Hat Based System" vars: packages: [ 'curl', 'git', 'htop' ] tasks: -name:Installalistofpackages yum:name={{item}}state=latest with_items:"{{ packages }}"
--- -hosts:web become:yes name:"Install Security Update" tasks: -name:"Installing Security Update on Red Hat Based System" yum:name=*update_cache=yessecurity=yesstate=latest when:ansible_facts['distribution']=="CentOS"
-name:"Installing Security Update on Ubuntu Based System" apt:upgrade=distupdate_cache=yes when:ansible_facts['distribution']=="Ubuntu"