https://www.puppet.com/community logo
Join Slack
Powered by
# puppet
  • v

    vchepkov

    08/08/2022, 2:12 PM
    Copy code
    class foo (
      $base_port,
      $secure_port = $base_port + 1000,
  • s

    silug

    08/08/2022, 2:26 PM
    the advantage of ⬆️ that is you can always override that
    secure_port
    default in hiera too
  • r

    runlolarun

    08/08/2022, 2:44 PM
    Hello, everyone. I can’t really test it right now, but will need to do it tomorrow and want to make sure I know for sure it will work. I need to remove certificates for a good amount of nodes. Can I run the following command
    puppet node clean *.<http://domain.edu|domain.edu>
    ?
  • r

    runlolarun

    08/08/2022, 2:44 PM
    Hello, everyone. I can’t really test it right now, but will need to do it tomorrow and want to make sure I know for sure it will work. I need to remove certificates for a good amount of nodes. Can I run the following command
    puppet node clean *.<http://domain.edu|domain.edu>
    ?
  • v

    vchepkov

    08/08/2022, 2:50 PM
    no
  • v

    vchepkov

    08/08/2022, 2:51 PM
    puppetserver ca list --all|grep pattern
  • v

    vchepkov

    08/08/2022, 2:52 PM
    and then awk or sed or cut
  • r

    runlolarun

    08/08/2022, 3:03 PM
    can you please elaborate..? I literally need to remove all nodes under one domain name. Wildcard will not work?
  • y

    Yorokobi

    08/08/2022, 3:07 PM
    Get the list of nodes to remove, stick 'em in a file or work with the list via pipes, loop over the lines (node names) in that file.
  • r

    runlolarun

    08/08/2022, 3:10 PM
    okay, it’s a solution. Thank you.
  • s

    Skylar Thompson

    08/08/2022, 3:17 PM
    I think
    puppet node clean
    can take in multiple node names, so could do something like this with
    xargs
    (remove
    echo
    when you're sure the output is right 🙂 ) -
    sudo puppetserver ca list --all|awk '$1 ~ /\.your-domain-here\.edu/ {print $1}'|xargs echo puppet node clean
  • s

    Skylar Thompson

    08/08/2022, 3:18 PM
    It would be a bit more efficient than a
    while
    loop, depending on how many nodes you're working on
  • v

    vchepkov

    08/08/2022, 3:20 PM
    isn't
    puppet node clean
    thing of the past?
  • v

    vchepkov

    08/08/2022, 3:21 PM
    in infinite wisdom, to make it more difficult it's
    puppetserver ca clean --certname cert1,cert2
    now
  • s

    Slackbot

    08/08/2022, 3:21 PM
    This message was deleted.
    v
    r
    s
    • 4
    • 4
  • s

    Slackbot

    08/08/2022, 3:21 PM
    This message was deleted.
    🙌🏼 1
    r
    v
    r
    • 4
    • 5
  • r

    Robert Vincent

    08/08/2022, 3:21 PM
    @runlolarun
    #!/bin/bash
    usage() {
    echo 'Usage:'
    echo "$0 <FQDN> [[<FQDN>]]"
    exit 1
    }
    # Exit with failure if no argument is given.
    [[ $# -lt 1 ]] && usage
    #
    # Strip tabs, returns, and linefeeds from arguments.
    ARGS="${*//[$'\t\r\n']}"
    # Convert to lowercase.
    CERTS="${ARGS,,}"
    # Combine into comma-delimited list.
    LIST="${CERTS// /,}"
    # Puppet primary hostname
    MOM=$(facter -p puppet_master_server)
    # Delete the node(s)
    TASK='/opt/puppetlabs/bin/puppet task run support_tasks::st0317b_purge_node'
    PARAMS="agent_certnames=${LIST} -n ${MOM}"
    echo "${TASK} ${PARAMS}" | tee -a $LOGFILE
    $TASK $PARAMS | sed -e '/^$/d; :x /\s*:\s*$/ { N; s/\s*:\s*\n\s*/ : /g ; bx }'
  • r

    Robert Vincent

    08/08/2022, 3:22 PM
    @runlolarun
    #!/bin/bash
    usage() {
    echo 'Usage:'
    echo "$0 <FQDN> [[<FQDN>]]"
    exit 1
    }
    # Exit with failure if no argument is given.
    [[ $# -lt 1 ]] && usage
    #
    # Strip tabs, returns, and linefeeds from arguments.
    ARGS="${*//[$'\t\r\n']}"
    # Convert to lowercase.
    CERTS="${ARGS,,}"
    # Combine into comma-delimited list.
    LIST="${CERTS// /,}"
    # Puppet primary hostname
    MOM=$(facter -p puppet_master_server)
    # Delete the node(s)
    TASK='/opt/puppetlabs/bin/puppet task run support_tasks::st0317b_purge_node'
    PARAMS="agent_certnames=${LIST} -n ${MOM}"
    echo "${TASK} ${PARAMS}"
    $TASK $PARAMS | sed -e '/^$/d; :x /\s*:\s*$/ { N; s/\s*:\s*\n\s*/ : /g ; bx }'
  • r

    Robert Vincent

    08/08/2022, 3:32 PM
    @runlolarun
    #!/bin/bash
    usage() {
    echo 'Usage:'
    echo "$0 <FQDN> [[<FQDN>]]"
    exit 1
    }
    # Exit with failure if no argument is given.
    [[ $# -lt 1 ]] && usage
    #
    # Strip tabs, returns, and linefeeds from arguments.
    ARGS="${*//[$'\t\r\n']}"
    # Convert to lowercase.
    CERTS="${ARGS,,}"
    # Combine into comma-delimited list.
    LIST="${CERTS// /,}"
    # Puppet primary hostname
    PRI=$(facter -p puppet_master_server)
    # Delete the node(s)
    TASK='/opt/puppetlabs/bin/puppet task run support_tasks::st0317b_purge_node'
    PARAMS="agent_certnames=${LIST} -n ${PRI}"
    echo "${TASK} ${PARAMS}"
    $TASK $PARAMS | sed -e '/^$/d; :x /\s*:\s*$/ { N; s/\s*:\s*\n\s*/ : /g ; bx }'
    # Run cleanup task on Compile Masters
    /opt/puppetlabs/bin/puppet job run -q "
    resources {
    type = 'Class' and
    title = 'Puppet_enterprise::Profile::Master' and
    !(certname = '${PRI}')
    }
    "
  • g

    Gerard Ryan

    08/08/2022, 3:53 PM
    Hi puppet! I have a Foreman deployment whose CA was set to expire on Saturday and I fortunately was able extend the CA certificate to 2037 using the ca_extend Bolt plan; however, while I did read the documentation and chose to distribute the CA via Puppet manifest, none of my agents can connect and they are reporting the CA has expired. 😞 Any help on this?
  • v

    vchepkov

    08/08/2022, 3:55 PM
    hopefully you have bolt configured or some other alternatives
  • g

    Gerard Ryan

    08/08/2022, 3:55 PM
    I do have bolt configured
  • v

    vchepkov

    08/08/2022, 3:55 PM
    just push new ca file and restart the agent
  • g

    Gerard Ryan

    08/08/2022, 3:55 PM
    For some of the inventory
  • g

    Gerard Ryan

    08/08/2022, 3:57 PM
    I don't understand where it failed. It must be that the updated CA certificate was not distributed to the agents?
  • g

    Gerard Ryan

    08/08/2022, 3:58 PM
    I don't understand where it failed. It must be that the updated CA certificate was not distributed to the agents?
  • v

    vchepkov

    08/08/2022, 3:59 PM
    correct, if you didn't deploy the code that would do it, there is nothing in place that would do it for you
  • v

    vchepkov

    08/08/2022, 4:00 PM
    kind of late to do it now via agent
  • g

    Gerard Ryan

    08/08/2022, 4:02 PM
    It was already done in a base module puppet manifest; I followed these intructions: https://forge.puppet.com/modules/puppetlabs/ca_extend#3-using-a-puppet-file-resource-to-manage-capem
  • s

    Slackbot

    08/08/2022, 4:04 PM
    This message was deleted.
    g
    v
    • 3
    • 47
1...125126127...428Latest