--- - 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 a tab character that violate indentation The error appears to be in '/etc/ansible/playbooks/apache1.yml': line 10, column 1, but may be elsewhere in the file depending on the exact syntax problem. The offending line appears to be: state: latest ^ here There appears to be a tab character at the start of the line.
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: Install a list of packages yum: name={{ item }} state=latest with_items: "{{ packages }}"