(command.CommandList
  children: [
    (C {<hash>} {<-r>})
    (command.ShFunction
      name: wait_for_ssh
      body: 
        (command.BraceGroup
          children: [
            (C {<local>} {<Id.Lit_VarLike 'hostname='> (DQ ($ Id.VSub_Number '$1'))})
            (C {<local>} 
              {<Id.Lit_VarLike 'min='> 
                (braced_var_sub
                  token: <Id.VSub_Number 2>
                  suffix_op: (suffix_op.Unary op_id:Id.VTest_ColonHyphen arg_word:{<1>})
                )
              } 
              {<Id.Lit_VarLike 'max='> 
                (braced_var_sub
                  token: <Id.VSub_Number 3>
                  suffix_op: (suffix_op.Unary op_id:Id.VTest_ColonHyphen arg_word:{<10>})
                )
              }
            )
            (command.If
              arms: [
                (if_arm
                  cond: [
                    (command.Sentence
                      child: 
                        (C {<Id.Lit_LBracket '['>} {<-z>} {(DQ (${ Id.VSub_Name hostname))} 
                          {<Id.Lit_RBracket ']'>}
                        )
                      terminator: <Id.Op_Semi _>
                    )
                  ]
                  action: [
                    (command.Sentence
                      child: (command.ControlFlow token:<Id.ControlFlow_Return return> arg_word:{<1>})
                      terminator: <Id.Op_Semi _>
                    )
                  ]
                  spids: [41 57]
                )
              ]
            )
            (command.Simple
              words: [{<exec>}]
              redirects: [(redir.Redir op:<Id.Redir_GreatAnd '3>&'> fd:3 arg_word:{<2>})]
            )
            (command.Simple
              words: [{<exec>}]
              redirects: [(redir.Redir op:<Id.Redir_Great '2>'> fd:2 arg_word:{</dev/null>})]
            )
            (command.WhileUntil
              keyword: <Id.KW_While while>
              cond: [(command.Sentence child:(C {<true>}) terminator:<Id.Op_Semi _>)]
              body: 
                (command.DoGroup
                  children: [
                    (command.If
                      arms: [
                        (if_arm
                          cond: [
                            (command.Sentence
                              child: 
                                (command.Simple
                                  words: [{<echo>}]
                                  redirects: [
                                    (redir.Redir
                                      op: <Id.Redir_Great '>'>
                                      fd: -1
                                      arg_word: {</dev/tcp/> (${ Id.VSub_Name hostname) </22>}
                                    )
                                  ]
                                )
                              terminator: <Id.Op_Semi _>
                            )
                          ]
                          action: [
                            (command.ControlFlow
                              token: <Id.ControlFlow_Return return>
                              arg_word: {<0>}
                            )
                          ]
                          spids: [89 103]
                        )
                      ]
                    )
                    (C {<sleep>} 
                      {
                        (word_part.ArithSub
                          anode: 
                            (arith_expr.Binary
                              op_id: Id.Arith_Plus
                              left: 
                                (arith_expr.Binary
                                  op_id: Id.Arith_Percent
                                  left: (arith_expr.ArithWord w:{($ Id.VSub_DollarName '$RANDOM')})
                                  right: (arith_expr.ArithWord w:{($ Id.VSub_DollarName '$max')})
                                )
                              right: (arith_expr.ArithWord w:{($ Id.VSub_DollarName '$min')})
                            )
                        )
                      }
                    )
                  ]
                )
            )
            (command.Simple
              words: [{<exec>}]
              redirects: [(redir.Redir op:<Id.Redir_GreatAnd '2>&'> fd:2 arg_word:{<3>})]
            )
            (command.Simple
              words: [{<exec>}]
              redirects: [(redir.Redir op:<Id.Redir_GreatAnd '3>&'> fd:3 arg_word:{<->})]
            )
          ]
        )
    )
    (command.ShFunction
      name: setup_headnodes
      body: 
        (command.BraceGroup
          children: [
            (command.AndOr
              ops: [Id.Op_DPipe]
              children: [
                (C {<bootstrap_head>} {<bcpc-vm1.bcpc.example.com>} {<10.0.100.11>})
                (C {<true>})
              ]
            )
            (C {<local>} {<Id.Lit_VarLike 'keyfile='> <Id.Lit_TildeLike '~'> </.ssh/id_rsa.root>})
            (command.If
              arms: [
                (if_arm
                  cond: [
                    (command.Sentence
                      child: 
                        (C {<Id.Lit_LBracket '['>} {<Id.KW_Bang '!'>} {<-r>} 
                          {(DQ (${ Id.VSub_Name keyfile))} {<Id.Lit_RBracket ']'>}
                        )
                      terminator: <Id.Op_Semi _>
                    )
                  ]
                  action: [
                    (command.AndOr
                      ops: [Id.Op_DPipe]
                      children: [
                        (C {<./install_root_key>})
                        (command.ShAssignment
                          pairs: [
                            (assign_pair
                              lhs: (sh_lhs_expr.Name name:keyfile)
                              op: assign_op.Equal
                              rhs: 
                                {(word_part.TildeSub token:<Id.Lit_TildeLike '~'>) 
                                  </.ssh/id_rsa.bcpc>
                                }
                              spids: [202]
                            )
                          ]
                        )
                      ]
                    )
                  ]
                  spids: [177 195]
                )
              ]
            )
            (C {<echo>} {(DQ <'Proceeding with second chef-client run'>)})
            (C {<ssh>} {<-i>} {(DQ (${ Id.VSub_Name keyfile))} {<-lroot>} {<10.0.100.11>} {<chef-client>})
          ]
        )
    )
    (command.ShFunction
      name: bootstrap_head
      body: 
        (command.BraceGroup
          children: [
            (C {<local>} {<Id.Lit_VarLike 'nodename='> (DQ ($ Id.VSub_Number '$1'))})
            (C {<local>} {<Id.Lit_VarLike 'ip='> (DQ ($ Id.VSub_Number '$2'))})
            (command.If
              arms: [
                (if_arm
                  cond: [
                    (command.Sentence
                      child: 
                        (C {<Id.Lit_LBracket '['>} {<-z>} {(DQ (${ Id.VSub_Name ip))} {<-o>} {<-z>} 
                          {(DQ (${ Id.VSub_Name nodename))} {<Id.Lit_RBracket ']'>}
                        )
                      terminator: <Id.Op_Semi _>
                    )
                  ]
                  action: [
                    (command.Sentence
                      child: (command.ControlFlow token:<Id.ControlFlow_Return return> arg_word:{<1>})
                      terminator: <Id.Op_Semi _>
                    )
                  ]
                  spids: [258 284]
                )
              ]
            )
            (command.TimeBlock
              pipeline: (C {<-p>} {<wait_for_ssh>} {(DQ (${ Id.VSub_Name ip))})
            )
            (C {<echo>} 
              {(DQ <'Configuring temporary hosts entry for chef server on '> (${ Id.VSub_Name ip))}
            )
            (C {<add_hosts_entries>} {(DQ (${ Id.VSub_Name ip))} {(DQ (${ Id.VSub_Name hosts_entries))})
            (C {<knife>} {<bootstrap>} {<--bootstrap-no-proxy>} {(DQ (${ Id.VSub_Name chef_server_host))} 
              {(${ Id.VSub_Name bootstrap_proxy_args)} {<-i>} {(DQ (${ Id.VSub_Name keyfile))} {<-x>} {<root>} 
              {<--node-ssl-verify-mode> <Id.Lit_Equals '='> <none>} {<--bootstrap-wget-options>} {(DQ <--no-check-certificate>)} {<-r>} {(SQ <'role[BCPC-Headnode]'>)} {<-E>} 
              {<Test-Laptop>} {(DQ (${ Id.VSub_Name ip))} {<-N>} {(DQ (${ Id.VSub_Name nodename))}
            )
            (command.Simple
              words: [{<knife>} {<actor>} {<map>}]
              redirects: [(redir.Redir op:<Id.Redir_GreatAnd '>&'> fd:-1 arg_word:{<2>})]
            )
            (command.Simple
              words: [{<knife>} {<group>} {<add>} {<actor>} {<admins>} {(DQ (${ Id.VSub_Name nodename))}]
              redirects: [(redir.Redir op:<Id.Redir_GreatAnd '>&'> fd:-1 arg_word:{<2>})]
            )
          ]
        )
    )
    (command.ShFunction
      name: bootstrap_worker
      body: 
        (command.BraceGroup
          children: [
            (C {<local>} {<Id.Lit_VarLike 'nodename='> (DQ ($ Id.VSub_Number '$1'))})
            (C {<local>} {<Id.Lit_VarLike 'ip='> (DQ ($ Id.VSub_Number '$2'))})
            (command.If
              arms: [
                (if_arm
                  cond: [
                    (command.Sentence
                      child: 
                        (C {<Id.Lit_LBracket '['>} {<-z>} {(DQ (${ Id.VSub_Name ip))} {<-o>} {<-z>} 
                          {(DQ (${ Id.VSub_Name nodename))} {<Id.Lit_RBracket ']'>}
                        )
                      terminator: <Id.Op_Semi _>
                    )
                  ]
                  action: [
                    (command.Sentence
                      child: (command.ControlFlow token:<Id.ControlFlow_Return return> arg_word:{<1>})
                      terminator: <Id.Op_Semi _>
                    )
                  ]
                  spids: [456 482]
                )
              ]
            )
            (command.TimeBlock
              pipeline: (C {<-p>} {<wait_for_ssh>} {(DQ (${ Id.VSub_Name ip))})
            )
            (C {<echo>} 
              {(DQ <'Configuring temporary hosts entry for chef server on '> (${ Id.VSub_Name ip))}
            )
            (C {<add_hosts_entries>} {(DQ (${ Id.VSub_Name ip))} {(DQ (${ Id.VSub_Name hosts_entries))})
            (C {<knife>} {<bootstrap>} {<--bootstrap-no-proxy>} {(DQ (${ Id.VSub_Name chef_server_host))} 
              {(${ Id.VSub_Name bootstrap_proxy_args)} {<-i>} {(DQ (${ Id.VSub_Name keyfile))} {<-x>} {<root>} {<--bootstrap-wget-options>} 
              {(DQ <--no-check-certificate>)} {<-r>} {(SQ <'role[BCPC-Worknode]'>)} {<-E>} {<Test-Laptop>} {(DQ ($ Id.VSub_DollarName '$ip'))} {<-N>} 
              {(DQ (${ Id.VSub_Name nodename))}
            )
          ]
        )
    )
    (command.ShFunction
      name: add_hosts_entries
      body: 
        (command.BraceGroup
          children: [
            (C {<local>} {<Id.Lit_VarLike 'ip='> (DQ ($ Id.VSub_Number '$1'))} 
              {<Id.Lit_VarLike 'entries='> (DQ ($ Id.VSub_Number '$2'))}
            )
            (command.If
              arms: [
                (if_arm
                  cond: [
                    (command.Sentence
                      child: 
                        (C {<Id.Lit_LBracket '['>} {<-z>} {(DQ (${ Id.VSub_Name ip))} {<-o>} {<-z>} 
                          {(DQ (${ Id.VSub_Name entries))} {<Id.Lit_RBracket ']'>}
                        )
                      terminator: <Id.Op_Semi _>
                    )
                  ]
                  action: [
                    (command.Sentence
                      child: (command.ControlFlow token:<Id.ControlFlow_Return return> arg_word:{<1>})
                      terminator: <Id.Op_Semi _>
                    )
                  ]
                  spids: [621 647]
                )
              ]
            )
            (C {<echo>} {($ Id.VSub_DollarName '$entries')})
            (command.Simple
              words: [
                {<ssh>}
                {<-ostricthostkeychecking> <Id.Lit_Equals '='> <no>}
                {<-i>}
                {(DQ (${ Id.VSub_Name keyfile))}
                {<-lroot>}
                {(DQ (${ Id.VSub_Name ip))}
              ]
              redirects: [
                (redir.HereDoc
                  op: <Id.Redir_DLess '<<'>
                  fd: -1
                  here_begin: {<EoF>}
                  here_end_span_id: 704
                  stdin_parts: [
                    <'  if ! getent ahosts bcpc-bootstrap &> /dev/null ; then\n'>
                    <'  cat <<EoS >> /etc/hosts\n'>
                    <'# Added by '>
                    (braced_var_sub
                      token: <Id.VSub_Number 0>
                      suffix_op: 
                        (suffix_op.Unary
                          op_id: Id.VOp1_DPound
                          arg_word: {<'*'> <Id.Lit_Slash />}
                        )
                    )
                    <'\n'>
                    ($ Id.VSub_DollarName '$entries')
                    <'\n'>
                    <'EoS\n'>
                    <'  fi\n'>
                    <'  getent hosts bcpc-bootstrap\n'>
                  ]
                )
              ]
            )
          ]
        )
    )
    (command.ShFunction
      name: configure_proxy
      body: 
        (command.BraceGroup
          children: [
            (command.If
              arms: [
                (if_arm
                  cond: [
                    (command.Sentence
                      child: 
                        (command.DBracket
                          expr: (bool_expr.Unary op_id:Id.BoolUnary_f child:{<./proxy_setup.sh>})
                        )
                      terminator: <Id.Op_Semi _>
                    )
                  ]
                  action: [
                    (C {<.>} {<./proxy_setup.sh>})
                    (C {<export>} {<-n>} 
                      (word.BracedTree
                        parts: [<http> (word_part.BracedTuple words:[{} {<s>}]) <_proxy>]
                      )
                    )
                  ]
                  spids: [714 725]
                )
              ]
            )
            (command.If
              arms: [
                (if_arm
                  cond: [
                    (command.Sentence
                      child: 
                        (command.DBracket
                          expr: 
                            (bool_expr.Unary
                              op_id: Id.BoolUnary_n
                              child: {(DQ (${ Id.VSub_Name https_proxy))}
                            )
                        )
                      terminator: <Id.Op_Semi _>
                    )
                  ]
                  action: [
                    (command.ShAssignment
                      pairs: [
                        (assign_pair
                          lhs: (sh_lhs_expr.Name name:bootstrap_proxy_args)
                          op: assign_op.Equal
                          rhs: {(DQ <'--bootstrap-proxy '> (${ Id.VSub_Name https_proxy))}
                          spids: [770]
                        )
                      ]
                    )
                  ]
                  spids: [751 767]
                )
              ]
              else_action: [
                (command.ShAssignment
                  pairs: [
                    (assign_pair
                      lhs: (sh_lhs_expr.Name name:bootstrap_proxy_args)
                      op: assign_op.Equal
                      rhs: {(DQ )}
                      spids: [782]
                    )
                  ]
                )
              ]
            )
          ]
        )
    )
    (command.ShFunction
      name: ip_to_name
      body: 
        (command.BraceGroup
          children: [
            (C {<local>} {<Id.Lit_VarLike 'ip='> (DQ ($ Id.VSub_Number '$1'))})
            (command.Simple
              words: [{<read>} {<_>} {<_>} {<_>} {<nodenum>}]
              redirects: [
                (redir.HereDoc
                  op: <Id.Redir_DLess '<<'>
                  fd: -1
                  here_begin: {<EoF>}
                  here_end_span_id: 834
                  stdin_parts: [($ Id.VSub_DollarName '$ip') <'\n'>]
                )
              ]
              more_env: [(env_pair name:IFS val:{(SQ <.>)} spids:[813])]
            )
            (command.If
              arms: [
                (if_arm
                  cond: [
                    (command.Sentence
                      child: 
                        (C {<Id.Lit_LBracket '['>} {<-z>} {(DQ (${ Id.VSub_Name ip))} {<-o>} {<-z>} 
                          {(DQ (${ Id.VSub_Name nodenum))} {<Id.Lit_RBracket ']'>}
                        )
                      terminator: <Id.Op_Semi _>
                    )
                  ]
                  action: [
                    (command.Sentence
                      child: (command.ControlFlow token:<Id.ControlFlow_Return return> arg_word:{<1>})
                      terminator: <Id.Op_Semi _>
                    )
                  ]
                  spids: [836 862]
                )
              ]
            )
            (C {<local>} 
              {<Id.Lit_VarLike 'suffix='> 
                (word_part.ArithSub
                  anode: 
                    (arith_expr.Binary
                      op_id: Id.Arith_Minus
                      left: (arith_expr.VarRef token:<Id.Lit_ArithVarLike nodenum>)
                      right: (arith_expr.ArithWord w:{<Id.Lit_Digits 10>})
                    )
                )
              }
            )
            (C {<echo>} {<bcpc-vm> (${ Id.VSub_Name suffix) <.> (${ Id.VSub_Name domainname)})
          ]
        )
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:domainname)
          op: assign_op.Equal
          rhs: {<bcpc.example.com>}
          spids: [900]
        )
      ]
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:chef_server_host)
          op: assign_op.Equal
          rhs: {<bcpc-bootstrap>}
          spids: [903]
        )
      ]
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:keyfile)
          op: assign_op.Equal
          rhs: {(word_part.TildeSub token:<Id.Lit_TildeLike '~'>) </.ssh/id_rsa.bcpc>}
          spids: [906]
        )
      ]
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:hosts_entries)
          op: assign_op.Equal
          rhs: {(DQ <'10.0.100.3 '> (${ Id.VSub_Name chef_server_host) <'\n'>)}
          spids: [910]
        )
      ]
    )
    (C {<Id.KW_Set set>} {<-e>})
    (C {<configure_proxy>})
    (C {<setup_headnodes>})
    (C {<echo>} {(DQ <'Waiting to bootstrap workers'>)})
    (C {<Id.KW_Set set>} {<-x>})
    (command.ForEach
      iter_name: ip
      iter_words: [
        (word.BracedTree
          parts: [<10.0.100.> (word_part.BracedRange kind:Id.Range_Int start:12 end:13 step:1)]
        )
      ]
      do_arg_iter: F
      body: 
        (command.DoGroup
          children: [
            (command.Sentence
              child: 
                (C {<eval>} 
                  {(DQ <'bootstrap_worker '>) 
                    (command_sub
                      left_token: <Id.Left_DollarParen '$('>
                      command_list: 
                        (command.CommandList
                          children: [(C {<ip_to_name>} {(${ Id.VSub_Name ip)})]
                        )
                    ) (DQ <' '> (${ Id.VSub_Name ip) <' &'>)
                  }
                )
              terminator: <Id.Op_Semi _>
            )
          ]
        )
    )
    (C {<wait>})
  ]
)