AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • Início
  • system&network
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • Início
  • system&network
    • Recentes
    • Highest score
    • tags
  • Ubuntu
    • Recentes
    • Highest score
    • tags
  • Unix
    • Recentes
    • tags
  • DBA
    • Recentes
    • tags
  • Computer
    • Recentes
    • tags
  • Coding
    • Recentes
    • tags
Início / user-898025

Martin's questions

Martin Hope
Martin
Asked: 2021-11-13 04:11:11 +0800 CST

Não é possível obter o UUID da partição de troca após criá-lo com o módulo do Parted ansible

  • 3

Eu tenho que criar uma nova partição em um disco novo em uma VM. Eu uso o módulo parted para criar a partição. Em uma tarefa futura (no mesmo playbook), preciso usar o UUID da partição do dispositivo (não o UUID da partição, mas o UUID do dispositivo da partição, presente por exemplo em /dev/disks/by-uuid/)

O problema é que: não encontro uma maneira de obter o UUID da partição em uma tarefa após o módulo parted ter arquivado o trabalho. Tenho certeza de que o módulo parted funciona bem porque a partição existe após a execução.

Vamos dar uma olhada no que eu tentei:

Creating the partition with the parted module
Re-launch facts with the setup module (with and without filtering on ansible_devices) in order to use the ansible_devices.sdX.partitions.sdXY.uuid --> return void
Use the blkid -s UUID -o value /dev/sdXY throught the shell module --> return void
Use the ls -l /dev/disk/by-uuid/ | grep sdXY | awk '{print $9}' throught the shell module --> still return void

O fato terrível é que: se eu lançar a mesma tarefa (como 2, 3 ou 4) em outro playbook, consigo obter resultados. Mas no mesmo manual do módulo parted: não posso.

Aqui está o meu playbook completo:

---
- hosts: all
  become: yes
  gather_facts: "yes"
  tasks:

   - name: Check actual swap quantity
     debug:
       var: ansible_swaptotal_mb
     failed_when: ansible_swaptotal_mb > 1999


   - name: Add a 2Gb disk
     shell: pwsh ./add_disk_vm.ps1 -vm {{ ansible_hostname }} -diskspace 2
     delegate_to: localhost


   - name: Scan for new disks
     shell: for i in $(ls /sys/class/scsi_host/); do echo "- - -" > /sys/class/scsi_host/$i/scan ; done

   - name: Get letter of the new disk
     shell: 'dmesg | grep "sd\w.*2.00 GiB)$" | grep -o "sd\w" | tail -1'
     register: diskletter


   - name: Create new partition
     community.general.parted:
       device: /dev/{{ diskletter.stdout }}
       fs_type: linux-swap
       label: gpt
       name: swap
       number: 1
       state: present
     register: parted


   #here the task who should work, but returning nothing
   - name: Get UUID
     shell: blkid -s UUID -o value /dev/{{ diskletter.stdout }}1
     register: uuidinfo

Eu não mencionei isso antes, mas a última tarefa funciona bem em outro playbook OU até mesmo diretamente no SSH na VM. O comando não retorna nada apenas durante o contexto de execução do playbook.

Aqui estão algumas outras informações sobre minha configuração:

ansible-playbook 2.9.27 python version = 2.7.17 Ubuntu 18.04 (onde o ansible está instalado E o servidor de destino) community.general collection (versão 3.7.0)

Se alguém tiver alguma ideia sobre isso; obrigado por tudo!

hard-drive ubuntu ansible parted
  • 2 respostas
  • 330 Views

Sidebar

Stats

  • Perguntas 205573
  • respostas 270741
  • best respostas 135370
  • utilizador 68524
  • Highest score
  • respostas
  • Marko Smith

    Você pode passar usuário/passar para autenticação básica HTTP em parâmetros de URL?

    • 5 respostas
  • Marko Smith

    Ping uma porta específica

    • 18 respostas
  • Marko Smith

    Verifique se a porta está aberta ou fechada em um servidor Linux?

    • 7 respostas
  • Marko Smith

    Como automatizar o login SSH com senha?

    • 10 respostas
  • Marko Smith

    Como posso dizer ao Git para Windows onde encontrar minha chave RSA privada?

    • 30 respostas
  • Marko Smith

    Qual é o nome de usuário/senha de superusuário padrão para postgres após uma nova instalação?

    • 5 respostas
  • Marko Smith

    Qual porta o SFTP usa?

    • 6 respostas
  • Marko Smith

    Linha de comando para listar usuários em um grupo do Windows Active Directory?

    • 9 respostas
  • Marko Smith

    O que é um arquivo Pem e como ele difere de outros formatos de arquivo de chave gerada pelo OpenSSL?

    • 3 respostas
  • Marko Smith

    Como determinar se uma variável bash está vazia?

    • 15 respostas
  • Martin Hope
    Davie Ping uma porta específica 2009-10-09 01:57:50 +0800 CST
  • Martin Hope
    kernel O scp pode copiar diretórios recursivamente? 2011-04-29 20:24:45 +0800 CST
  • Martin Hope
    Robert ssh retorna "Proprietário incorreto ou permissões em ~/.ssh/config" 2011-03-30 10:15:48 +0800 CST
  • Martin Hope
    Eonil Como automatizar o login SSH com senha? 2011-03-02 03:07:12 +0800 CST
  • Martin Hope
    gunwin Como lidar com um servidor comprometido? 2011-01-03 13:31:27 +0800 CST
  • Martin Hope
    Tom Feiner Como posso classificar a saída du -h por tamanho 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich O que é um arquivo Pem e como ele difere de outros formatos de arquivo de chave gerada pelo OpenSSL? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent Como determinar se uma variável bash está vazia? 2009-05-13 09:54:48 +0800 CST

Hot tag

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • Início
  • Perguntas
    • Recentes
    • Highest score
  • tag
  • help

Footer

AskOverflow.Dev

About Us

  • About Us
  • Contact Us

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve