This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ tree roles/ | |
roles/ | |
└── gitlab_pipeline | |
├── defaults | |
│ └── main.yml | |
├── handlers | |
│ └── main.yml | |
├── meta | |
│ └── main.yml | |
├── README.md |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
2 #Author: Amaury Borges Souza | |
3 #Description: Basic role to install Docker | |
4 #YML name: installing_docker_app.yml | |
5 #Ansible_Version: 2.9.6 | |
6 - name: Installing Docker Engine | |
7 hosts: localhost | |
8 become: true | |
9 gather_facts: false | |
10 roles: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
#Author: Amaury Borges Souza | |
#Description: Basic role to install Docker | |
#YML name: installing_docker_app.yml | |
#Contact: [email protected] | |
#Ansible_Version: 2.9.6 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ansible-playbook installing_docker_app.yml --tags=update |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- hosts: web_servers | |
tasks: | |
- name: Run a shell command and register its output as a variable | |
ansible.builtin.shell: /usr/bin/foo | |
register: foo_result | |
ignore_errors: true | |
- name: Run a shell command using output of the previous task | |
ansible.builtin.shell: /usr/bin/bar | |
when: foo_result.rc == 5 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- hosts: prod | |
become: true | |
gather_facts: false | |
vars: | |
package: git | |
tasks: | |
- name: Install packages on system | |
apt: | |
name={{ package }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- name: teste | |
hosts: localhost | |
become: true | |
gather_facts: false | |
vars: | |
package: nmap | |
tasks: | |
- name: Install packages on system | |
apt: name={{ package }} state=latest |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- name: add several users | |
user: | |
name: "{{ item }}" | |
groups: "wheel" | |
state: present | |
with_items: | |
- testuser1 | |
- testuser2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tasks: | |
- name: Configure SELinux to start mysql on any port | |
ansible.posix.seboolean: | |
name: mysql_connect_any | |
state: true | |
persistent: yes | |
when: ansible_selinux.status == "enabled" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tasks: | |
- name: Shut down Debian flavored systems | |
ansible.builtin.command: /sbin/shutdown -t now | |
when: ansible_facts['os_family'] == "Debian" |