User Tools

Site Tools


ansible_manager_roles_nfs

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

ansible_manager_roles_nfs [2025/07/26 17:09] – - Imported by DokuWiki Advanced Plugin wikiadmansible_manager_roles_nfs [Unknown date] (current) – removed - external edit (Unknown date) 127.0.0.1
Line 1: Line 1:
-====== Gerenciar Roles no Ansible - NFS Server ====== 
-<file bash> 
-$ sudo ansible-galaxy role init nfs-server 
-- Role nfs-server was created successfully 
-</file> 
  
-<file bash> 
-$ sudo ansible-galaxy role list 
-# /etc/ansible/roles 
-- conf-base, 1.0.0 
-- nfs-server, (unknown version) 
-</file> 
- 
-<file bash> 
-$ sudo cp -r ~/roles/nfs-server/* nfs-server/ 
-$ sudo cp -r ~/roles/nfs-server/*.* nfs-server/ 
-</file> 
- 
-**Conteúdo do diretório tasks:** 
-  * **main.yml:** Arquivo principal responsável em carregar os arquivos ''install.yml'' e ''configure.yml''; 
-  * **install.yml:** Arquivo responsável pela instalação do NFS; 
-  * **configure.yml:** Arquivo responsável pela configuração do NFS. 
- 
-<file yaml> 
-$ cat nfs-server/meta/main.yml 
---- 
-galaxy_info: 
-  role_name: nfs-server 
-  author: 4Linux DevOps 
-  description: Instalacao e Configuracao do servidor NFS 
-  company: 4Linux 
-  license: GPLv3 
-  min_ansible_version: 2.9 
-  platforms: 
-    - name: Ubuntu 
-      versions: 
-        - focal 
-    - name: EL 
-      versions: 
-        - 8 
-  galaxy_tags: 
-    - nfs 
-dependencies: 
-  - conf-base 
-</file> 
- 
-<file yaml> 
-$ cat nfs-server/tasks/main.yml 
---- 
-- name: Define instalacao do servidor NFS 
-  import_tasks: install.yml 
- 
-- name: Define configuracao do servidor NFS 
-  import_tasks: configure.yml 
-</file> 
- 
-<file bash> 
-$ cat nfs-server/tasks/configure.yml 
---- 
-- name: Inicia o serviço rpcbind 
-  service: 
-    name: rpcbind 
-    state: started 
- 
-- name: Define o arquivo de configuracao do servidor NFS no Debian/Ubuntu 
-  when: ansible_os_family == "Debian" 
-  copy: 
-    src: exports 
-    dest: /etc/exports 
-    owner: root 
-    group: root 
-    mode: 0644 
-  notify: 
-    - Restart NFS Ubuntu 
-  tags: nfs 
- 
-- name: Define o arquivo de configuracao do servidor NFS no RedHat/CentOS 
-  when: ansible_os_family == "RedHat" 
-  copy: 
-    src: exports 
-    dest: /etc/exports 
-    owner: root 
-    group: root 
-    mode: 0644 
-  notify: 
-    - Restart NFS CentOS 
-  tags: nfs 
- 
-- name: Verifica se diretorio /opt/site/admin existe 
-  stat: 
-    path: /opt/site/admin 
-  register: site_directory 
- 
-- name: Criando diretorio site 
-  when: not site_directory.stat.exists 
-  copy: 
-    src: site/ 
-    dest: /opt/site 
-    owner: root 
-    group: root 
-  tags: nfs 
-</file> 
- 
-<file bash> 
-$ cat nfs-server/tasks/install.yml 
---- 
-- name: Instala servidor NFS no Debian/Ubuntu 
-  when: ansible_os_family == "Debian" 
-  apt: 
-    name: nfs-kernel-server 
-    state: present 
-    update_cache: true 
-  notify: 
-    - Start NFS Ubuntu 
-  tags: nfs 
- 
-- name: Instala servidor NFS no RedHat/CentOS 
-  when: ansible_os_family == "RedHat" 
-  yum: 
-    name: nfs-utils 
-    state: present 
-  notify: 
-    - Start NFS CentOS 
-  tags: nfs 
- 
-- name: Inicia e ativa na inicializacao o servico NFS 
-  when: ansible_os_family == "RedHat" 
-  systemd: 
-    name: nfs-server 
-    state: started 
-    enabled: true 
-  tags: nfs 
-</file> 
- 
-<file bash> 
-$ cat nfs-server/handlers/main.yml 
---- 
-- name: Start NFS Ubuntu 
-  when: ansible_os_family == "Debian" 
-  service: 
-    name: nfs-kernel-server 
-    state: started 
- 
-- name: Restart NFS Ubuntu 
-  when: ansible_os_family == "Debian" 
-  ansible.builtin.command: "exportfs -va" 
- 
-- name: Start NFS CentOS 
-  when: ansible_os_family == "RedHat" 
-  service: 
-    name: nfs-server 
-    state: started 
- 
-- name: Restart NFS CentOS 
-  when: ansible_os_family == "RedHat" 
-  ansible.builtin.command: "exportfs -va" 
-</file> 
- 
-<file bash> 
-$ cat nfs-server/files/exports 
-/opt/site 10.240.0.0/16(rw,no_root_squash,no_subtree_check) 
-</file> 
- 
-<file yaml> 
-$ cat ~/roles/playbooks/nfs-server.yml 
---- 
-- hosts: ol-vm-02 
-  vars: 
-    ansible_python_interpreter: /usr/bin/python3.9 
-  roles: 
-    - nfs-server 
-</file> 
- 
-<file bash> 
-$ sudo ansible-playbook --syntax-check ~/roles/playbooks/nfs-server.yml 
- 
-playbook: /home/vagrant/roles/playbooks/nfs-server.yml 
-</file> 
- 
-<file bash> 
-$ sudo ansible-playbook ~/roles/playbooks/nfs-server.yml 
- 
-PLAY [ol-vm-02] ************************************************************************************************************************************************************************************************* 
- 
-TASK [Gathering Facts] ****************************************************************************************************************************************************************************************** 
-ok: [ol-vm-02] 
- 
-TASK [conf-base : Testando entradas no arquivo /etc/hosts] ****************************************************************************************************************************************************** 
-ok: [ol-vm-02] 
- 
-TASK [conf-base : Limpa o arquivo /etc/hosts] ******************************************************************************************************************************************************************* 
-skipping: [ol-vm-02] 
- 
-TASK [conf-base : Configuracao do arquivo /etc/hosts] *********************************************************************************************************************************************************** 
-ok: [ol-vm-02] => (item={'ip': '127.0.0.1', 'fqdn': 'localhost.localdomain', 'alias': 'localhost'}) 
-ok: [ol-vm-02] => (item={'ip': '10.240.0.200', 'fqdn': 'ansible-server.juntotelecom.com.br', 'alias': 'ansible-server'}) 
-ok: [ol-vm-02] => (item={'ip': '10.240.0.201', 'fqdn': 'ub-vm-01.juntotelecom.com.br', 'alias': 'ub-vm-01'}) 
-ok: [ol-vm-02] => (item={'ip': '10.240.0.202', 'fqdn': 'ol-vm-02.juntotelecom.com.br', 'alias': 'ol-vm-02'}) 
-ok: [ol-vm-02] => (item={'ip': '10.240.0.203', 'fqdn': 'de-vm-03.juntotelecom.com.br', 'alias': 'de-vm-03'}) 
- 
-TASK [conf-base : Instala pacotes base no Debian/Ubuntu] ******************************************************************************************************************************************************** 
-skipping: [ol-vm-02] 
- 
-TASK [conf-base : Instala pacotes base no RedHat/CentOS 7] ****************************************************************************************************************************************************** 
-skipping: [ol-vm-02] 
- 
-TASK [conf-base : Instala pacotes base no RedHat/CentOS 8] ****************************************************************************************************************************************************** 
-skipping: [ol-vm-02] 
- 
-TASK [conf-base : Adiciona usuario HelpDesk] ********************************************************************************************************************************************************************ok: [ol-vm-02] 
- 
-TASK [conf-base : Adiciona usuario DevOps] ********************************************************************************************************************************************************************** 
-ok: [ol-vm-02] 
- 
-TASK [nfs-server : Instala servidor NFS no Debian/Ubuntu] ******************************************************************************************************************************************************* 
-skipping: [ol-vm-02] 
- 
-TASK [nfs-server : Instala servidor NFS no RedHat/CentOS] ******************************************************************************************************************************************************* 
-changed: [ol-vm-02] 
- 
-TASK [nfs-server : Inicia e ativa na inicializacao o servico NFS] *********************************************************************************************************************************************** 
-changed: [ol-vm-02] 
- 
-TASK [nfs-server : Inicia o serviço rpcbind] ******************************************************************************************************************************************************************** 
-ok: [ol-vm-02] 
- 
-TASK [nfs-server : Define o arquivo de configuracao do servidor NFS no Debian/Ubuntu] *************************************************************************************************************************** 
-skipping: [ol-vm-02] 
- 
-TASK [nfs-server : Define o arquivo de configuracao do servidor NFS no RedHat/CentOS] *************************************************************************************************************************** 
-changed: [ol-vm-02] 
- 
-TASK [nfs-server : Verifica se diretorio /opt/site/admin existe] ************************************************************************************************************************************************ 
-ok: [ol-vm-02] 
- 
-TASK [nfs-server : Criando diretorio site] ********************************************************************************************************************************************************************** 
-changed: [ol-vm-02] 
- 
-RUNNING HANDLER [nfs-server : Start NFS CentOS] ***************************************************************************************************************************************************************** 
-ok: [ol-vm-02] 
- 
-RUNNING HANDLER [nfs-server : Restart NFS CentOS] *************************************************************************************************************************************************************** 
-changed: [ol-vm-02] 
- 
-PLAY RECAP ****************************************************************************************************************************************************************************************************** 
-ol-vm-02                   : ok=13   changed=5    unreachable=0    failed=0    skipped=6    rescued=0    ignored=0 
-</file> 
- 
-<file bash> 
-$ sudo ansible ol-vm-02 -m shell -e 'ansible_python_interpreter=/usr/bin/python3.9' -a 'showmount -e' 
-ol-vm-02 | CHANGED | rc=0 >> 
-Export list for ol-vm-02: 
-/opt/site 172.17.0.0/16,172.16.0.0/16 
-</file> 
ansible_manager_roles_nfs.1753560543.txt.gz · Last modified: by wikiadm